Cod sursa(job #1223957)
| Utilizator | Data | 29 august 2014 11:47:26 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.56 kb |
#include <fstream>
#include <cmath>
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
const long long MOD = 1999999973;
long long a, b;
void Putere();
int main()
{
fin >> a >> b;
Putere();
fin.close();
fout.close();
return 0;
}
void Putere()
{
long long p = 1;
while ( b > 0 )
{
if ( b % 2 )
{
p *= a;
p %= MOD;
}
a = a * a;
a %= MOD;
b /= 2;
}
p %= MOD;
fout << p << '\n';
}
