-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathAMOEBA.cpp
More file actions
24 lines (23 loc) · 803 Bytes
/
AMOEBA.cpp
File metadata and controls
24 lines (23 loc) · 803 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
#include<stdio.h>
int t[]={3,19,99,499,4999,49999,499999,4999999,49999999};
int main(){
long long int n;
while(scanf("%lld",&n)!=EOF){
long long int temp;
if(n==1){printf("1\n");continue;}
temp=n;
long long int cntr=1,cnt=0;
while(temp>0){temp/=10;cntr*=10;cnt++;}
long long int num=1,day=1;
int s=t[cnt]+1;
//printf("%d\n",s);
while(s--!=0&&num!=n){
num=(num*7)%cntr;
day++;
}
//printf("%d\n",s);
if(s==-1){printf("-1\n");continue;}
printf("%d\n",day);
}
return 0;
}