File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ import java .util .Scanner ;
2+
3+ public class c1091 {
4+
5+ public static void main (String [] args ) {
6+
7+ Scanner sc = new Scanner (System .in );
8+ String [] nums = sc .nextLine ().split (" " );
9+ sc .close ();
10+
11+ long a = Integer .parseInt (nums [0 ]); //시작값
12+ int m = Integer .parseInt (nums [1 ]); //곱할값
13+ int d = Integer .parseInt (nums [2 ]); //더할값
14+ int n = Integer .parseInt (nums [3 ]); //몇번째인지 나타내는 숫자
15+
16+ //int에 넘치므로 long으로
17+ //-50 50 -50 10 => -99649234693877550
18+
19+ for (int i =0 ; i <n -1 ; i ++) {
20+ a = (a *m +d );
21+ }
22+ System .out .println (a );
23+
24+
25+ /* 연습
26+ System.out.println(1*-2+1); //-1
27+ System.out.println(-1*-2+1); //3
28+ System.out.println(3*-2+1); //-5
29+ System.out.println(-5*-2+1); //11
30+ */
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments