首页 > 代码库 > 1003-Hangover

1003-Hangover

#include<iostream>
using namespace std;
double jisuan(double a)
{
double sum=0;
for(double i=2;i<=a+1;i++)
{
sum=sum+double(1/i);
}
return sum;
}
int main()
{
	double a;
	cin>>a;
	while(a!=0)
	{
	if(0<=a<0.5)
		cout<<1<<" "<<"card(s)"<<endl;  
	 else
	 	for(int i=1;i>=0;i++)
	 		if(jisuan(i)>=a)
	 		{
	 			cout<<i<<" "<<"card(s)"<<endl;
	 			break;
	 		}
	cin>>a;
    } 
	return 0;
 } 

  

1003-Hangover