forked from deepakgarg0802/MyCompetitiveCodingSolutions
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbase.cpp
49 lines (43 loc) · 932 Bytes
/
base.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
#include<bits/stdc++.h>
#define MAX 100000
#define DEBUG(x) do { std::cout << #x << ": " << x << std::endl; } while (0)
using namespace std;
int main(){
long long t,n,i,count,j,x,rem,quo;
cin>>t;
while(t--)
{
cin>>x;
n=x;
count=0;
if(x==1){
cout<<"INFINITY\n";
continue;
}
if(x==0){
cout<<"0\n";
continue;
}
for(i=2;i<x;++i)
{
//DEBUG(i);
n=x;
rem=n%i;
quo=n/i;
//DEBUG(rem);
//DEBUG(quo);
while(quo!=0){
n=quo;
rem=n%i;
quo=n/i;
//DEBUG(rem);
//DEBUG(quo);
}
if(rem==1){
++count;
}
}
cout<<count+1<<endl;
}
return 0;
}