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

请教一下,这样为什么不对啊,有人可以给些测试数据吗

Posted by ly50247 at 2009-04-17 15:02:35 on Problem 1650
#include <iostream>
//#include <cstring>
#include <cmath>
//#include <cstdlib>
//#include <algorithm>
//#include <string>
using namespace std;

int main()
{
	double num;
	int limit;
	cin >> num >> limit;
	double min = 10000;
	int fi, fi2;
	for (int i=1; i <= limit; i++)
	{
		if ((int)(i*num+0.5) > limit )
			break;
		double tmp = fabs(i*num-(int)(i*num+0.5));
		if (min > tmp )
		{
			min = tmp;
			fi = i;
			fi2 = (int)(i*num+0.5);
		}
	
	
	}
	cout << fi2 << ' ' << fi;
	
	
	
	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