[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/artbataev/timus_cpp/master/task_1110.cpp [Back]  [Original]

#include 

int x_pow_n_mod_m(int x, int n, int m) {
    int result = 1;
    for(int i = 0; i < n; i++) {
        result = (result * x) % m;
        if (result == 0)
            break;
    }
    return result;
}

int main() {
    std::ios::sync_with_stdio(false);
    int n, m, y;
    std::cin >> n >> m >> y;
    bool found = false;

    for(int i = 0; i < m; i++) {
        if (x_pow_n_mod_m(i, n, m) == y) {
            if(found)
                std::cout 

Web Proxy Viewer  |  New URL  |  Original Page