117. Counting
time limit per test: 0.5 sec.
memory limit per test: 4096 KB
Find amount of numbers for given sequence of integer numbers such that after raising them to the M-th power they will be divided by K.
Input
Input consists of two lines. There are three integer numbers N, M, K (0<N, M, K<10001) on the first line. There are N positive integer numbers ? given sequence (each number is not more than 10001) ? on the second line.
Output
Write answer for given task.
Sample Input
4 2 509 10 11 12
Sample Output
1Author | : Michael R. Mirzayanov |
Resource | : PhTL #1 Training Contests |
Date | : Fall 2001 |
SGU中难得的水题。。。。怒A。。。
#include <iostream> #include <cstring> #include <cstdio> #include <cmath> using namespace std; int prim[11000]; int sigK[11000],sigA[11000]; int main() { int n,m,k; cin>>n>>m>>k; memset(prim,-1,sizeof(prim)); prim[1]=prim[0]=0; for(int i=2;i<=sqrt(11000);i++) { if(prim for(int j=2*i;j<11000;j+=i) { prim[j]=0; } } for(int i=0;i<11000;i++) { if(prim { while(k%i==0) { k/=i; sigK } } } int ans=0; for(int i=0;i<n;i++) { int a; cin>>a; memset(sigA,0,sizeof(sigA)); for(int j=0;j<11000;j++) { if(prim[j]!=0) { while(a%j==0) { a/=j; sigA[j]++; } sigA[j]*=m; } } bool OK=true; for(int j=0;j<11000;j++) { if(sigK[j]) { if(sigA[j]<sigK[j]) { OK=false; break; } } } if(OK) ans++; } cout<<ans<<endl; return 0; } |