Cod sursa(job #2370040)
Utilizator | Data | 6 martie 2019 10:25:34 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,s=1;
int p;
long long MOD=1999999973;
int main()
{
f>>n>>p;
while(p)
{
if(p%2==1)
s=(s*n)%MOD;
n=(n*n)%MOD;
p=p/2;
}
g<<s;
return 0;
}