You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
555 B
C
38 lines
555 B
C
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int pow_(int x, int y) {
|
|
if (!y) {
|
|
return 1;
|
|
}
|
|
int res = x;
|
|
for (int i = 1; i <= y-1; ++i) {
|
|
res = res*x;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
int main(int argc, char *argv[]) {
|
|
char z[10000];
|
|
if (argc)
|
|
strcpy(z, argv[1]);
|
|
|
|
float x;
|
|
int y;
|
|
scanf("%f %x", &x, &y);
|
|
|
|
int len = strlen(z);
|
|
int res = 0;
|
|
for (int i = len-1; i >= 0; --i) {
|
|
if (z[i]>='0' && z[i]<='9') {
|
|
res += (z[i] - '0') * pow_(27, len-i-1);
|
|
}
|
|
else {
|
|
res += (z[i] - 'A' + 10) * pow_(27, len-i-1);
|
|
}
|
|
}
|
|
printf("%.3f\n", x+y+res);
|
|
}
|
|
|
|
|