Skip to content

Commit 74c4bf6

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

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

โ€Ž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)