• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

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

Author : Michael R. Mirzayanov
Resource : PhTL #1 Training Contests
Date : Fall 2001
 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 }
View Code
posted @ 2014-02-03 19:48  HaibaraAi  阅读(93)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3