Cod sursa(job #3291451)
Utilizator | Data | 4 aprilie 2025 18:48:32 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include<bits/stdc++.h>
#define mod 1999999973
using namespace std;
long long n , p =1 ,a;
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int main()
{
fin >> a >> n;
while(n)
{
if(n % 2 == 1)
{
p = p * a;
p %= mod;
}
a *= a;
a %= mod;
n /= 2;
}
fout << p;
}