-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathday25.java
More file actions
34 lines (29 loc) · 764 Bytes
/
day25.java
File metadata and controls
34 lines (29 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
import java.util.Scanner;
public class day25 {
static int modPow(int base, int exp, int mod) {
long x = 1;
while (exp > 0) {
x = (x * base) % mod;
--exp;
}
return (int)x;
}
static int solve(int base, int mod, int target) {
long x = 1;
int i = 0;
while (x != target) {
x = (base * x) % mod;
++i;
}
return i;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int card = in.nextInt();
int door = in.nextInt();
in.close();
int exp = solve(7, 20201227, card);
int answer = modPow(door, exp, 20201227);
System.out.println(answer);
}
}