简单的考察对浮点数使用的水题

HDOJ2009_求数列的和

HDOJ2009_求数列的和

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<math.h> 

using namespace std;

int main()
{
	int n,m;
	int i,j;
	while(scanf("%d %d",&n,&m)!=EOF)
	{
		//计算数列的前n项和
		double sum=n;
		double tmp=n;
	
		for(i=1;i<m;i++)
		{		
			tmp=(double)sqrt(tmp);
			sum+=tmp;
		}
		printf("%.2lf\n",sum);
	}
	return 0;
}

相关文章:

  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
  • 2021-11-08
  • 2022-12-23
  • 2021-04-10
  • 2022-01-24
  • 2022-12-23
猜你喜欢
  • 2021-10-06
  • 2021-11-28
  • 2021-11-10
  • 2021-04-07
相关资源
相似解决方案