Cod sursa(job #3298193)
Utilizator | Data | 27 mai 2025 21:27:58 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
const int mod = 1999999973;
long long pw(long long a, long long n){
long long ans = 1;
while(n > 0){
if(n % 2 == 1){
ans = (ans * a) % mod;
}
a = (a * a) % mod;
n /= 2;
}
return ans;
}
int main()
{
int a, b;
f >> a >> b;
g << pw(a,b);
}