Cod sursa(job #1960007)
| Utilizator | Data | 10 aprilie 2017 09:37:05 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.62 kb |
#include <iostream>
#include <cstdio>
using namespace std;
FILE *f, *g;
#define fs fscanf
#define fp fprintf
#define mod 1999999973
typedef long long lint;
lint x, n;
lint lgput(lint x, lint n)
{
lint p = 1;
while(n)
{
if(n & 1)
{
p*=x;
p%=mod;
n--;
}
x*=x;
x%=mod;
n >>= 1;
}
return p;
}
int main()
{
f = fopen("lgput.in", "r");
g = fopen("lgput.out", "w");
fs(f, "%lld%lld", &x, &n);
fp(g, "%lld", lgput(x, n));
return 0;
}
