Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // C++ program to print all prime factors
- #include <bits/stdc++.h>
- using namespace std;
- // A function to print all prime
- // factors of a given number n
- int primeFactors(int n)
- {
- int cnt=0;
- // Print the number of 2s that divide n
- while (n % 2 == 0)
- {
- //cout << 2 << " ";
- cnt++;
- n = n/2;
- }
- // n must be odd at this point. So we can skip
- // one element (Note i = i +2)
- for (int i = 3; i <= sqrt(n); i = i + 2)
- {
- // While i divides n, print i and divide n
- while (n % i == 0)
- {
- cnt++;
- // cout << i << " ";
- n = n/i;
- }
- }
- // This condition is to handle the case when n
- // is a prime number greater than 2
- if (n > 2)cnt++;
- // cout << n << " ";
- return cnt;
- }
- /* Driver code */
- int main()
- {
- int t;
- cin>>t;
- while(t--)
- {
- int n,k;
- cin>>n>>k;
- int cnt= primeFactors(n);
- if(k<=cnt)cout<<1<<endl;
- else cout<<0<<endl;
- }
- }
- // This is code is contributed by rathbhupendra
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement