Cod sursa(job #1622559)
| Utilizator | Data | 1 martie 2016 12:20:22 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <bits/stdc++.h>
#define mod 1999999973
#define ll long long
using namespace std;
ifstream f("lgput.in");
ofstream g("lgput.out");
ll x, y;
void read() {
f>>x>>y;
}
ll fast(ll x, ll p) {
if (p == 0) return 1;
if (p % 2 == 0) return (fast((x*x)%mod, p/2))%mod;
return (x*(fast((x*x)%mod, p-1)%mod))%mod;
}
int main() {
read();
g<<fast(x,y)<<'\n';
f.close(); g.close();
return 0;
}
