Cod sursa(job #2187872)
| Utilizator | Data | 26 martie 2018 19:44:06 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
using namespace std;
ifstream f ("lgput.in");
ofstream g ("lgput.out");
const long long mod=1999999973;
long long sol=1ll,a,b;
int main()
{
f>>a>>b;
while(b)
{
if(b%2)
{
sol=sol*a;
while(sol>mod) sol-=mod;
}
b/=2;
a=a*a;
while(a>mod) a-=mod;
}
g<<sol;
return 0;
}
