hdu 2009 求数列的和
求数列的和
思路:利用sqrt函数计算根号,再依次累计相加
代码:
#include<iostream> #include<math.h> using namespace std; int main() { double m, n; double num, sum; while (cin >> m >> n) { sum = 0; num = m; int i; for (i = 0; i < n; i++) { sum += num; num = sqrt(num); } printf("%0.2lf\n", sum); } system("pause"); return 0; }