Cod sursa(job #1969963)
Utilizator | Data | 18 aprilie 2017 19:16:26 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
typedef long long ll;
#define mod 1999999973
ll lgput(ll a,ll b)
{
ll c=1;
while(b)
{
if(b%2==1)
{c*=a;c%=mod;}
a*=a;
b/=2;
a%=mod;
}
return c;
}
int main()
{
int a,b;
f>>a>>b;
g<<lgput(a,b);
return 0;
}