Cod sursa(job #1585729)
| Utilizator | Data | 31 ianuarie 2016 13:35:13 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
unsigned long long a , b;
unsigned long long ridicare(int x, int n)
{
unsigned long long p = 1 ;
while (n > 0)
{
if ((n & 1))
{
p = ((p * x ) % mod);
--n;
}
else
{
x = (x * x)%mod ;
n >>= 1 ;
}
}
return p ;
}
int main()
{
f >> a >> b;
g << ridicare(a , b);
return 0;
}
