Cod sursa(job #1906876)
Utilizator | Data | 6 martie 2017 16:47:56 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.41 kb |
#include <iostream>
#include <fstream>
using namespace std;
const int mod = 1999999973;
int main()
{
ifstream i("lgput.in");
ofstream o("lgput.out");
unsigned long long n, p, x = 1;
i >> n >> p;
while(p)
{
if(p % 2)
{
x = (x * n) % mod;
}
p /= 2;
n = (n * n) % mod;
}
o << p;
return 0;
}