Cod sursa(job #3257928)
| Utilizator | Data | 19 noiembrie 2024 22:50:34 | |
|---|---|---|---|
| Problema | Ridicare la putere in timp logaritmic | Scor | 100 |
| Compilator | c-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <stdio.h>
#define p 1999999973
int main(){
long long b, ans, pow;
FILE *fin, *fout;
fin = fopen( "lgput.in", "r" );
fscanf( fin, "%lld%lld", &b, &pow );
fclose( fin );
ans = 1;
while ( pow > 0 ) {
if ( pow % 2 == 1 )
ans = (ans * b) % p;
pow = pow / 2;
b = (b * b) % p;
}
fout = fopen( "lgput.out", "w" );
fprintf( fout, "%lld\n", ans );
fclose( fout );
return 0;
}
