Cod sursa(job #1712533)
Utilizator | Data | 3 iunie 2016 00:14:58 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.45 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
int x,n;
fin >> x >> n;
int y=1;
while (n>1)
{
if (n%2==0)
{
x=1LL*x*x%mod;
n=n/2;
}
else
{
y=1LL*x*y%mod;
x=1LL*x*x%mod;
n=(n-1)/2;
}
}
int rasp= 1LL*x*y%mod;
fout << rasp;
return 0;
}