-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathStrangeNo.cpp
More file actions
63 lines (62 loc) · 1.03 KB
/
Copy pathStrangeNo.cpp
File metadata and controls
63 lines (62 loc) · 1.03 KB
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
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool isPrime(int n){
for(int i = 2; i <= sqrt(n); ++i)
{
if(n % i == 0)
{
return false;
break;
}
}
return true;
}
ll kfactors(int n){
int j=0;
while (n%2 == 0)
{
n/=2;
j++;
}
for (int i=3; i<=sqrt(n); i=i+2)
{
while (n%i == 0)
{
n = n/i;
j++;
}
}
if(n>2){ j++; }
return j;
}
int main()
{
ll x,k,t;
cin>>t;
while(t--){
cin>>x>>k;
if(x==1){ cout<<0<<"\n";}
else if(k==1){
cout<<1<<"\n";
}
else if(k==2){
if(!isPrime(x)){
cout<<1<<"\n";
}
else{
cout<<0<<"\n";
}
}
else{
if(kfactors(x)>=k){
cout<<1<<"\n";
}
else{
cout<<0<<"\n";
}
}
}
return 0;
}