Cod sursa(job #2187877)
| Utilizator | Data | 26 martie 2018 19:45:29 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 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&1)
{
sol=sol*a;
while(sol>=mod) sol-=mod;
}
b>>=1;
a=a*a;
while(a>=mod) a-=mod;
}
g<<sol;
return 0;
}
