Cod sursa(job #1412327)
Utilizator | Data | 1 aprilie 2015 11:26:11 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <fstream>
#define mod 1999999973
#define ll long long
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
ll x, y;
ll putere(ll a, ll b)
{
if (b==0) return 1;
if (b%2==0) return putere(a*a, b/2) % mod;
if (b%2==1) return (a*putere(a,b-1))%mod;
}
int main()
{
f>>x>>y;
g<<putere(x,y)%mod<<'\n';
return 0;
}