Cod sursa(job #317045)
Utilizator | Data | 22 mai 2009 11:52:11 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.27 kb |
#include <fstream>
#define C 1999999973
using namespace std;
ifstream f1 ("lgput.in");
ofstream f2 ("lgput.out");
int main()
{
long long a,b,sol=1;
f1>>a>>b;
while(b)
{
if(b%2) sol=(sol*a)%C;
a=(a*a)%C;
b/=2;
}
f2<<sol;
return 0;
}