Cod sursa(job #1622563)
| Utilizator | Data | 1 martie 2016 12:21:10 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.45 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)/2)%mod))%mod;
}
int main() {
read();
g<<fast(x,y)<<'\n';
f.close(); g.close();
return 0;
}
