Cod sursa(job #1921033)
Utilizator | Data | 10 martie 2017 11:09:02 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include<fstream>
#include<cstdio>
#define p 1999999973
#define ll long long
using namespace std;
ll x=1,a,b;
void lg(ll a,ll b)
{
if(b&1)
{
x=((x%p)*a)%p;
b--;
}
a=(a%p)*(a%p)%p;
b>>=1;
if(b)
lg(a,b);
}
int main()
{
freopen("lgput.in","r",stdin);
ofstream g("lgput.out");
scanf("%ld%ld",&a,&b);
lg(a,b);
g<<x;
return 0;
}