-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount.cpp
93 lines (73 loc) · 1.01 KB
/
count.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include <iostream>
using namespace std;
int arr[1000];
int j;
int main()
{
bool cmp();
int t,n;
int on;
cin>>t;
cout<<"\n";
for(int i=1;i<=t;i++)
{
cin>>on;
for(int x=0;x<1000;x++)
arr[x]=-1;
int k=0;
j=1;
int cn;
bool val=false;
while(j<1000 && val!=true )
{
n=on*j;
cn=n;
//cout<<"\t\n"<<n<<"\t\n"<<on;
while (n!=0)
{
arr[k]=n%10;
n/=10;
k++;
}
val=cmp();
j++;
}
if(val==true &&on!=0)
{
cout<<"Case #"<<i<<": "<<cn<<endl;
}
else
cout<<"Case #"<<i<<": "<<"INSOMNIA"<<endl;
// for(int y=0;y<100;y++)
//cout<<arr[y]<<"\t";
//cout<<"\n\n"<<k;
}
}
bool cmp()
{
int ret[10]={0,0,0,0,0,0,0,0,0,0};
for(int ic = 0; ic < 10; ic++)
{
for (int jc = 0; jc < 1000; jc++)
{
if (arr[jc]==ic)
{
ret[ic]=11;
}
}
//cout<<"\n\n\n"<<ic<<"\t"<<ret[ic];
}
bool allEqual=true;
for (int z=0; z<9; z++) {
if (ret[z] != ret[z+1])
allEqual=false;
}
//cout<<"\n\nThe "<<allEqual;
if (allEqual==true)
{
return true;
j=1000;
}
else
return false;
}