Cod sursa(job #2572062)
Utilizator | Data | 5 martie 2020 11:26:45 | |
---|---|---|---|
Problema | Ridicare la putere in timp logaritmic | Scor | 10 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <fstream>
#define mod 1999999973
using namespace std;
ifstream f ( "lgput.in" );
ofstream g ( "lgput.out" );
int x, p;
int main()
{ f >> x >> p;
int r = 1;
while ( p != 0 ){
if ( p % 2 == 1 )
r = r * x % mod;
x = x * x % mod;
p /= 2;
}
g << r;
return 0;
}