Cod sursa(job #1649894)
Utilizator | Data | 11 martie 2016 15:37:44 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
int n,p;
long long x=1LL;
f>>n>>p;
while (p)
{
if (p%2) x=(x*n)%mod;
n=(n*n)%mod;
p/=2;
}
g<<x<<'\n';
f.close();
g.close();
return 0;
}