Cod sursa(job #365010)
| Utilizator | Data | 17 noiembrie 2009 17:22:38 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include <iostream>
#include <fstream>
std::ifstream fin("lgput.in");
std::ofstream fout("lgput.out");
long long int expmod(long long int n,long long int p)
{
if (p == 0) return 1;
if (p % 2 == 1) return (n * expmod(n, p-1)) % 1999999973;
long long x = expmod(n, p / 2) % 1999999973;
return x * x % 1999999973;
}
int main()
{
long long a,b;
fin >> a >> b;
fout << expmod(a, b);
}
