Cod sursa(job #2049175)
Utilizator | Data | 26 octombrie 2017 21:59:09 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
int main()
{
ifstream f("lgput.in");
ofstream g("lgput.out");
int a,b;
unsigned long long rez=1;
f>>a>>b;
while(b>0){
if(b%2==1){
rez=rez*a%mod;
b--;
}
if(b>0){
b=b/2;
rez=rez*rez%mod;
}
}
g<<rez%mod;
}