Cod sursa(job #2662876)
| Utilizator | Data | 24 octombrie 2020 18:44:24 | |
|---|---|---|---|
| Problema | Factorial | Scor | 0 |
| Compilator | c-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <stdio.h>
#include <ctype.h>
int main() {
FILE *fin, *fout;
int b, k, x;
char ch;
fin = fopen( "gsr.in", "r" );
fscanf( fin, "%d%d", &b, &k );
fgetc( fin );
x = 0;
ch = fgetc( fin );
while ( ch != '\n' ) {
if ( isalpha( ch ) )
x = ((long long)x * b + 10 + ch - 'A') % k;
else
x = ((long long)x * b + ch - '0') % k;
ch = fgetc( fin );
}
fclose( fin );
fout = fopen( "gsr.out", "w" );
fprintf( fout, "%d", x );
fclose( fout );
return 0;
}
