-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblem 26.cpp
56 lines (54 loc) · 1.22 KB
/
Problem 26.cpp
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//ANSWER IS 983
//EXECUTION PROCESS TAKES 0.531 SECONDS
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n=2,ans=2,num=1,i,j,k;
long max=0,curr=0;
while(n<1000)
{
cout<<n<<"\n";
curr=0;num=1;
vector <int> a(n);
for(i=0;i<n;i++)
a[i]=0;
int flag=0,f1=0;
while(flag==0&&f1==0)
{
k=num%n;
if(k==0)
{
flag=0;
break;
}
else
{
if(a[k]>0)
{
f1=1;
curr++;
break;
}
else
{
a[k]++;
curr++;
}
}
num=k;
num*=10;
}
if(f1==1)
{
curr-=a[k];
if(curr>max)
{
max=curr;
ans=n;
}
}
n++;
}
cout<<ans<<" "<<max;
}