Submission #692928
Source Code Expand
#include<iostream>
using namespace std;
long long func(long long n, long long m, long long p)
{
if(p==0)
return 1;
else if(p%2==0){
long long buf = func(n,m,p/2);
return buf * buf % m;
}
else
return func(n,m,p-1)*n % m;
}
long long func2()
{
return 0;
}
int main()
{
long long N,M,P;
cin >> N >> M >> P;
cout << func(N,M,P) << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | B - n^p mod m |
| User | be116 |
| Language | C++14 (GCC 5.4.1) |
| Score | 100 |
| Code Size | 392 Byte |
| Status | AC |
| Exec Time | 6 ms |
| Memory | 256 KiB |
Judge Result
| Set Name | Sample | All | ||
|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 100 / 100 | ||
| Status | AC |
|
| 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 | 4 ms | 256 KiB |
| 017.txt | AC | 4 ms | 256 KiB |
| 018.txt | AC | 6 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 |