Cod sursa(job #668345)
Utilizator | Data | 24 ianuarie 2012 18:48:18 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
#include <fstream>
using namespace std;
int comb[2][1000001];
int pow (int a,int b) {
int rez=1;
while (b) {
if (b%2) {
rez*=a;
b--;
rez%=1999999973;
}
a*=a;
b/=2;
}
return rez;
}
int main() {
int n,i,l,k;
ifstream f("lgput.in");
ofstream g("lgput.out");
f>>n>>k;
g<<pow(n,k);
g.close();
return 0;
}