Cod sursa(job #941755)
| Utilizator | Data | 19 aprilie 2013 17:40:30 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const int mod = 1999999973;
ll powmod(ll a, int n) {
ll ret = 1;
while (n != 0) {
if (n & 1) {
ret *= a;
ret %= mod;
}
a *= a;
a %= mod;
n >>= 1;
}
return ret;
}
int main() {
ifstream fin("lgput.in");
ofstream fout("lgput.out");
int a, n;
fin >> a >> n;
fout << powmod(a, n);
return 0;
}
