Cod sursa(job #3280711)
| Utilizator | Data | 27 februarie 2025 11:49:57 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin ("lgput.in");
ofstream fout ("lgput.out");
const int ct = 1999999973;
int main()
{
fin.tie(0); fin.sync_with_stdio(false);
ll a, b; fin>>a>>b;
ll power = 1;
while (b) {
if (b%2==1) power*=a; //Neaparat in ordinea asta in while (descompunerea in baza 2)
a*=a;
b/=2;
if (a>=ct) a%=ct;
if (power>=ct) power%=ct;
}
fout<<power;
return 0;
}
//2^4 = 100
//