Cod sursa(job #2949461)
| Utilizator | Data | 30 noiembrie 2022 18:12:51 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int a,b;
int putere(int a, int b)
{
int p;
p = 1;
while(b > 0)
{
if(b % 2 == 1) p = 1LL * p * a % MOD;
b/=2;
a = 1LL * a * a % MOD;
}
return p;
}
int main()
{
fin >> a >> b;
fout << putere(a,b);
fin.close();
fout.close();
return 0;
}
