zoukankan      html  css  js  c++  java
  • 2009.求数列的和

    #include<stdio.h>

    #include<stdlib.h>

    #include<math.h>

    int main(){

             int n,m,i,a;

             float s=n;

             scanf("%d%d",&n,&m);

             for(i=1;i<=m;i++){

                       n=sqrt(n);

                       s+=n;       

             }

             printf("%.2f",s);

             return 0;

    }

    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
  • 相关阅读:
    halcon7月license
    软设考试成绩查询结果
    Halcon自学笔记
    Window_Store
    Windows_Store之2048
    基于C#开发的2048
    MVC+EF+EasyUI实现CRUD
    ASP.NET MVC Model验证总结
    浙江省三级数据库考试
    基于C#的短信发送
  • 原文地址:https://www.cnblogs.com/huoyuying/p/9734130.html
Copyright © 2011-2022 走看看