Cod sursa(job #937915)
Utilizator | Data | 11 aprilie 2013 12:18:52 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
#include <iostream>
using namespace std;
int main()
{
const int mod=1999999973;
unsigned long long n,k,res=1;
ifstream f("lgput.in");
f>>n>>k;
f.close();
while(k>0)
{
if(k%2==1)
{
res*=n;
res%=mod;
k--;
}
n*=n;
n%=mod;
k/=2;
}
ofstream h("lgput.out");
h<<res;
h.close();
return 0;
}