Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

为啥我这样做5.19求出272张卡

Posted by ranzhouhua at 2019-07-18 17:11:24 on Problem 1003
#include<iostream>
using namespace std;

int hangover( double x)
{
	int n=1;
	double cardlength,a,b;
	cardlength = 1.0 / (n + 1);
	for (cardlength;cardlength<x;cardlength += 1.0 / (n + 1))
	{
		n++;
	}
	a = cardlength-1.0/(n+1);
	b = cardlength;
	if ((x - a) > (b - x))
	{
		return n;
	}
	else
		return n-1;
}

int main()
{
	double x;
	while (cin >> x&&x!=0.00)
	{
		int	 n=hangover(x);
		cout << n << " card(s)" << endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator