Cod sursa(job #1263220)
Utilizator | Data | 14 noiembrie 2014 09:47:23 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <fstream>
using namespace std;
const int mod = 1999999973;
ifstream f("lgput.in");
ofstream g("lgput.out");
long long a,b,p;
int main()
{
f >> a >> b;
p=1;
while (b!=1)
{
if (b%2==1)
p*=a;
a=a*a;
a=a%mod;
p=p%mod;
b/=2;
}
g<<a*p % mod;
return 0;
}