Cod sursa(job #1876296)
| Utilizator | Data | 12 februarie 2017 11:08:51 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.38 kb |
#include <bits/stdc++.h>
#define tip long long
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
const tip MOD=1999999973;
tip b,e,putere(tip,tip);
int main()
{
f>>b>>e;
g<<putere(b,e);
return 0;
}
tip putere(tip b,tip e)
{
tip p=1;
for(;e;e/=2)
{
if(e%2)p=(p*b)%MOD;
b=(b*b)%MOD;
}
return p;
}
