Cod sursa(job #1990990)
Utilizator | Data | 14 iunie 2017 15:38:53 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
int n,p,x,sol;
int m=1999999973;
int main()
{f>>x>>n;
p = 1 ;
while (n > 0)
{
if (n & 1)
{
p*=x;
n--;
}
x=x*x;
n=n/2;
}
sol=p%m;
g<<sol;
}