Submission #691529


Source Code Expand

#include <iostream>

using namespace std;

long long N, M, P;

long long pow_mod(long long n, long long m, long long p) {
    if (p == 0) return 1;
    else if (p % 2 == 1) return pow_mod(n, m, p - 1) * n % m;
    else {
        long long t = pow_mod(n, m, p / 2);
        return t * t % m;
    }
}

void solve() {
    cin >> N >> M >> P;
    cout << pow_mod(N, M, P) << endl;
}

int main() {
    solve();
    return 0;
}

Submission Info

Submission Time
Task B - n^p mod m
User ysd
Language C++14 (GCC 5.4.1)
Score 100
Code Size 446 Byte
Status AC
Exec Time 56 ms
Memory 384 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status AC
AC × 27
Set Name Test Cases
Sample
All 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt
Case Name Status Exec Time Memory
001.txt AC 4 ms 256 KiB
002.txt AC 4 ms 256 KiB
003.txt AC 4 ms 256 KiB
004.txt AC 4 ms 256 KiB
005.txt AC 4 ms 256 KiB
006.txt AC 4 ms 256 KiB
007.txt AC 4 ms 256 KiB
008.txt AC 4 ms 256 KiB
009.txt AC 4 ms 256 KiB
010.txt AC 4 ms 256 KiB
011.txt AC 4 ms 256 KiB
012.txt AC 4 ms 256 KiB
013.txt AC 4 ms 256 KiB
014.txt AC 4 ms 256 KiB
015.txt AC 4 ms 256 KiB
016.txt AC 56 ms 384 KiB
017.txt AC 4 ms 256 KiB
018.txt AC 4 ms 256 KiB
019.txt AC 4 ms 256 KiB
020.txt AC 4 ms 256 KiB
021.txt AC 4 ms 256 KiB
022.txt AC 4 ms 256 KiB
023.txt AC 4 ms 256 KiB
024.txt AC 4 ms 256 KiB
025.txt AC 4 ms 256 KiB
026.txt AC 4 ms 256 KiB
027.txt AC 4 ms 256 KiB
sample_01.txt AC 4 ms 256 KiB
sample_02.txt AC 4 ms 256 KiB