Cod sursa(job #1560787)
Utilizator | Data | 3 ianuarie 2016 12:24:09 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
# include <cstdio>
# define MOD 1999999973
using namespace std;
long long a,b,sol=1;
int main()
{
freopen("lgput.in", "r", stdin);
freopen("lgput.out", "w", stdout);
scanf("%lld %lld\n", &a,&b);
while(b)
{
if(b%2==0) a=(a*a)%MOD,b/=2;
else sol=(sol*a)%MOD,b--;
}
printf("%lld\n", sol);
}