Cod sursa(job #1586988)
Utilizator | Data | 1 februarie 2016 19:19:21 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.21 kb |
#include <fstream>
using namespace std;long long x,y,d=1,k=1999999973;ifstream fin("lgput.in");ofstream fout("lgput.out");int main (){fin>>x>>y;while(y>0){if(y%2){d=(d*x)%k;}x=(x*x)%k;y/=2;}fout<<d;return 0;}