Cod sursa(job #2360274)
Utilizator | Data | 1 martie 2019 16:54:51 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
using namespace std;
ifstream fin("lgput.in") ;
ofstream fout("lgput.out") ;
int main()
{
long long a , b , sol = 1 ;
fin >> a >> b ;
while ( b > 0 )
{
if ( b&1 )
sol = (sol * a)%MOD ; ;
b = b>>1 ;
a = (a*a)%MOD ;
}
fout << sol ;
}