50198. Two Digits
難度:2/51
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#include <stdio.h>
#include <stdlib.h>
int con_2_dig(int x){
int cnt[10] = {0};
while(x){
cnt[x % 10]++;
x /= 10;
}
int cnt_not_0 = 0;
for(int i = 0; i < 10; i++) if(cnt[i] != 0) cnt_not_0++;
return cnt_not_0 <= 2;
}
void solve(int a, int b, int x){
while(!con_2_dig(x)){
x = (a * x) % b;
}
printf("%d\n", x);
}
int main(){
int a, b, x;
while(scanf("%d %d %d", &a, &b, &x) != EOF){
solve(a, b, x);
}
}
50198. Two Digits
https://aaronlin1229.github.io/judgegirl_50198/