Cod sursa(job #2032691)
Utilizator | Data | 5 octombrie 2017 16:22:16 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <stdio.h>
#define ll long long
const ll mod = 1999999973;
ll p(ll x,ll n)
{
ll rez = 1;
ll pow = x;
for(int i = 0;i<32;i++,pow=(pow*pow)%mod)
if((1<<i) & n)
rez = (rez * pow) % mod;
return rez;
}
ll n;
int main()
{
fscanf(fopen("lgput.in","r"),"%lld",&n);
fprintf(fopen("lgput.out","w"),"%lld",p(7,n));
return 0;
}