Cod sursa(job #1210292)
| Utilizator | Data | 19 iulie 2014 16:23:43 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.55 kb |
#include <iostream>
#include <fstream>
using namespace std;
long long Lgput(int n, int k){
if(k > 0){
if(k % 2 != 0){
return (n % 1999999973 * Lgput(n % 1999999973 , k - 1)) % 1999999973;
}
else{
return Lgput(n % 1999999973 * n % 1999999973 , k / 2) % 1999999973;
}
}
else{
return 1;
}
}
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
long long n,k;
f>>n;
f>>k;
g<<Lgput(n , k) % 1999999973;
return 0;
}
