博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
杭电oj -2009 求数列的和 C++
阅读量:4034 次
发布时间:2019-05-24

本文共 432 字,大约阅读时间需要 1 分钟。

Problem Description

数列的定义如下:
数列的第一项为n,以后各项为前一项的平方根,求数列的前m项的和。

Input

输入数据有多组,每组占一行,由两个整数n(n<10000)和m(m<1000)组成,n和m的含义如前所述。

Output

对于每组输入数据,输出该数列的和,每个测试实例占一行,要求精度保留2位小数。

Sample Input

81 4
2 2

Sample Output

94.73
3.41

代码

#include
#include
#include
using namespace std;int main(){ int n,m; double sum; while(cin>>n>>m){ double nn=double(n); sum=0.0; sum+=nn; for(int i=0;i

转载地址:http://safdi.baihongyu.com/

你可能感兴趣的文章
免费馅饼
查看>>
Common Subsequence
查看>>
Humble Numbers
查看>>
Merge Intervals
查看>>
Insert Interval
查看>>
Trapping Rain Water
查看>>
Pow(x, n)
查看>>
Sort Colors
查看>>
Restore IP Addresses
查看>>
Word Break II
查看>>
Anagrams
查看>>
Letter Combinations of a Phone Number
查看>>
Combination Sum
查看>>
Combination Sum II
查看>>
Word Search
查看>>
Count and Say
查看>>
Palindrome Partitioning
查看>>
Palindrome Partitioning II
查看>>
python配置libsvm(win7)
查看>>
Q22:栈的压入、弹出序列
查看>>