forked from sowon-dev/AlgorithmStudy_Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathc1091.java
More file actions
34 lines (25 loc) ยท 764 Bytes
/
c1091.java
File metadata and controls
34 lines (25 loc) ยท 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package codeup100;
import java.util.Scanner;
public class c1091 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] nums = sc.nextLine().split(" ");
sc.close();
long a = Integer.parseInt(nums[0]); //์์๊ฐ
int m = Integer.parseInt(nums[1]); //๊ณฑํ ๊ฐ
int d = Integer.parseInt(nums[2]); //๋ํ ๊ฐ
int n = Integer.parseInt(nums[3]); //๋ช๋ฒ์งธ์ธ์ง ๋ํ๋ด๋ ์ซ์
//int์ ๋์น๋ฏ๋ก long์ผ๋ก
//-50 50 -50 10 => -99649234693877550
for(int i=0; i<n-1; i++) {
a = (a*m+d);
}
System.out.println(a);
/* ์ฐ์ต
System.out.println(1*-2+1); //-1
System.out.println(-1*-2+1); //3
System.out.println(3*-2+1); //-5
System.out.println(-5*-2+1); //11
*/
}
}