zoukankan      html  css  js  c++  java
  • HDU_2009——数列的前m项和

    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
     1 #include <cstdio>
     2 #include <cmath>
     3 int main()
     4 {
     5    int n,m;
     6    while(~scanf("%d %d",&n,&m))
     7       {
     8          double ans=n,f=n;
     9          for(int i=1;i<m;i++)
    10             {
    11                f=sqrt(f);
    12                ans=ans+f;
    13             }
    14          printf("%.2lf\n",ans);   
    15       }
    16    return 0;
    17 }
    ——现在的努力是为了小时候吹过的牛B!!
  • 相关阅读:
    会场安排
    Comet OJ
    CodeForces1154F
    CodeForces1154E
    2019.08.25校内模拟赛Graph
    2019.08.25校内模拟赛Page
    [MtOI2019]灵梦的计算器
    [MtOI2019]永夜的报应
    [NOI2018]归程
    USACO[CowCoupons]
  • 原文地址:https://www.cnblogs.com/pingge/p/3138147.html
Copyright © 2011-2022 走看看