Cod sursa(job #2412422)
| Utilizator | Data | 22 aprilie 2019 11:25:48 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 50 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <fstream>
using namespace std;
ifstream in ("lgput.in");
ofstream out ("lgput.out");
unsigned long long rise(long long a,long long b)
{
long long x;
if(b==0)return 1%1999999973;
else{
x=(rise(a,b/2))%1999999973;
if(b%2==1)return ((x%1999999973)*(a%1999999973)*(x%1999999973))%1999999973;
else{return ((x%1999999973)*(x%1999999973))%1999999973;}
}
}
int main()
{unsigned long long a,b;
in>>a>>b;
out<<rise(a,b)%1999999973;
return 0;
}
