Cod sursa(job #2385268)
Utilizator | Data | 21 martie 2019 19:03:04 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | excelenta-tema2 | Marime | 0.4 kb |
#include <fstream>
#define MOD 1999999973
#define ll long long
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
ll a, b;
ll put(ll a, ll b)
{
ll rez=1;
while(b)
{
if(b%2)
rez= (rez*a)%MOD;
a*=a;
b/=2;
}
return rez;
}
int main()
{
f>> a >> b;
g<< put(a,b);
g.close();
f.close();
return 0;
}