Cod sursa(job #911307)
| Utilizator | Data | 11 martie 2013 15:14:47 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 20 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include<fstream>
#define ull unsigned long long
using namespace std;
int a, b, c=1999999973;
ifstream f("lgput.in");
ofstream g("lgput.out");
ull putere(int x, int n)
{
if(n==0) return 1;
else
{
ull aux=putere(x, n/2);
if(n%2) return (aux*aux)%c*(x%c);
else return (aux*aux)%c;
}
}
int main()
{
f>>a>>b;
g<<putere(a,b);
return 0;
}
