#include #include #include #include #define LINE_SIZE 1024 int main() { char line[LINE_SIZE]; char* endptr = NULL; char* start = NULL; memset(line, 0, LINE_SIZE); char* r1 = fgets(line, LINE_SIZE, stdin); assert(r1 != NULL); double x = strtod(line, NULL); memset(line, 0, LINE_SIZE); char* r2 = fgets(line, LINE_SIZE, stdin); assert(r2 != NULL); int len = strlen(line); start = line; double result = 0.0; int first = 1; while (start < (line + len)) { double val = strtod(start, &endptr); if (start != endptr) { if (first) { result = val; first = 0; } else { result = result * x + val; } start = endptr; } else { break; } } return 0; }