Counting

题目大意:求下面N个数里面有多少个数的M次方能整除K

代码如下:

========================================================

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

const int MAXN = 10007;
const int oo = 1e9+7;

int QuickPow(int a, int b, int Mod)
{
    int t = 1;

    while(b)
    {
        if(b & 1)
            t = (t * a) % Mod;
        a = (a * a) % Mod;

        b >>= 1;
    }

    return t;
}

int main()
{
    int a, b, N, Mod, ans=0;

    scanf("%d%d%d", &N, &b, &Mod);

    while(N--)
    {
        scanf("%d", &a);
        if(QuickPow(a, b, Mod) == 0)
            ans++;
    }

    printf("%d
", ans);

    return 0;
}
原文地址:https://www.cnblogs.com/liuxin13/p/4817521.html