题解 | #数列的和#
数列的和
https://www.nowcoder.com/practice/fe19f8a78a5148018f4be53ae9b5e11e
#include <stdio.h> #include "math.h" int main() { int a[10000], b[10000], n = 0; double tmp = 0, sum = 0; while (scanf("%d %d", &a[n], &b[n]) != EOF) { // 注意 while 处理多个 case // 64 位输出请用 printf("%lld") to n++; } for(int i = 0; i < n; i++) { for(int j = 0; j < b[i]; j++) { if(j == 0) { tmp = a[i]; } else { tmp = sqrt(tmp); } sum += tmp; } printf("%.2f\n", sum); sum = 0; } return 0; }