Skip to content

Commit 74c4bf6

Browse files
authored
Create c1091.java
1 parent 2684df3 commit 74c4bf6

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/codeup100/c1091.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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+
}

0 commit comments

Comments
 (0)