Sgu 117
|
117. Counting time limit per test: 0.25 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 50 9 10 11 12 Sample Output 1 |
||||||
|
1 #pragma comment(linker,"/STACK:102400000,102400000") 2 #include <cstdio> 3 #include <vector> 4 #include <cmath> 5 #include <queue> 6 #include <set> 7 #include <cstring> 8 #include <iostream> 9 #include <algorithm> 10 using namespace std; 11 #define INF 0x7fffffff 12 #define mod 1000000007 13 #define ll long long 14 #define maxn 100025 15 #define pi acos(-1.0) 16 int n, m, k; 17 ll Pow(ll a, ll b){ 18 ll res = 1; 19 while (b){ 20 if (b & 1)res = (res*a) % k; 21 a = (a*a) % k; 22 b >>= 1; 23 } 24 return res; 25 } 26 int main(){ 27 int t=0, x; 28 scanf("%d%d%d", &n,&m,&k); 29 for (int i = 0; i < n; i++){ 30 scanf("%d", &x); 31 if (Pow(x, m) == 0)t++; 32 } 33 printf("%d\n", t); 34 return 0; 35 }
浙公网安备 33010602011771号