Cod sursa(job #2467779)
Utilizator | Data | 5 octombrie 2019 08:12:54 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <bits/stdc++.h>
#define MOD 1999999973
using namespace std;
ifstream fin("lqput.in");
ofstream fout("lgput.out");
int lgput(int a, int n)
{
int p = 1;
while(n)
{
if(n % 2 == 1) p = p * a % MOD;
n /= 2;
a = a * a % MOD;
}
return p;
}
int main()
{
cout << lgput(2, 10);
return 0;
}