Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdio>
- #define MAX 1e18
- using namespace std;
- int main()
- {
- int t,n,k;
- cin>>t;
- while(t--)
- {
- cin>>n>>k;
- int ans=0,flag=0;
- long long num;
- for(int i=0;i<n;i++)
- {
- scanf("%lld",&num);
- //check whether num is a power of k or not
- while(num>=1)
- {
- if(num==1)
- {
- flag=1;break;
- }
- if(num%k != 0)
- {
- flag=0;break;
- }
- num=num/k;
- }
- if(flag)
- {
- ans++;flag=0;
- }
- }
- cout<<ans<<endl;
- }
- }
Add Comment
Please, Sign In to add comment