Cod sursa(job #1015594)
Utilizator | Data | 24 octombrie 2013 21:08:53 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
unsigned long long n,val,p;
int main()
{
f >> n >> p;
val = 1;
while(p != 0)
{
if(p % 2 != 0) val = (val * n) % 1999999973;
n = (n * n) % 1999999973;
p = p / 2;
}
g << val;
return 0;
}