p117.ans1
======================
1

=================
p117.cpp
======================
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

int n, m, k;
vector<int> a;

void read() {
    cin >> n >> m >> k;
    a.resize(n);
    cin >> a;
}

int pw(int x, int p) {
    int r = 1 % k;
    while(p) {
        if(p & 1) {
            r = r * 1ll * x % k;
        }

        x = x * 1ll * x % k;
        p >>= 1;
    }

    return r;
}

void solve() {
    // A number v^M is divisible by K iff v^M mod K == 0, computed with fast
    // modular exponentiation. Count how many values in the sequence satisfy
    // this.

    int answer = 0;
    for(int v: a) {
        answer += pw(v, m) == 0;
    }

    cout << answer << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}

=================
p117.in1
======================
4 2 50
9 10 11 12

=================
statement.txt
======================
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

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