# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3724 | solveit | Great Pow! (kriii1_G) | C++98 | 0 ms | 1672 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <string>
#include <math.h>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <vector>
#include <stdio.h>
using namespace std;
#define ll long long
int MOD;
ll pow(int base, int exp) {
if(exp == 1) {
return base%MOD;
}
if(exp%2) {
return (base *((pow(base, exp/2) * pow(base, exp/2))%MOD))%MOD;
}
return (pow(base, exp/2) * pow(base, exp/2))%MOD;
}
int main() {
int a, k;
scanf("%d %d",&a,&k);
MOD = a + 1;
if(k == 0)
printf("%d\n", a);
else
printf("%lld\n", pow(a, a));
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |