Cod sursa(job #2210475)
| Utilizator | Data | 6 iunie 2018 19:56:14 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include<cstdio>
#define MOD 1999999973
using namespace std;
typedef long long unsigned llu;
llu Pow(llu n, llu p) {
llu res = 1;
while(p) {
if(p & 1)
res = (res*n) % MOD;
n = (n*n) % MOD;
p >>= 1;
}
return res;
}
int main() {
int n, p;
FILE* fin, *fout;
fin = fopen("lgput.in","r");
fout = fopen("lgput.out","w");
fscanf(fin,"%d%d",&n,&p);
fprintf(fout,"%llu\n",Pow(n,p));
fclose(fin);
fclose(fout);
return 0;
}
