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 frkstyc at 2006-03-31 13:58:00 on Problem 2140
In Reply To:show yi xia Posted by:2004huangyimin at 2006-03-31 13:40:29

> #include < iostream >
> using namespace std;
> bool IsInterOrNot( double a )
> {
> 	int b;
> 	if ( a > 0 )
> 	{
> 		b = (int)a;
> 		if ((a - b) == 0){ return true; }
> 		else { return false; }
> 	}
> 	else { return false; }
> }
> int main()
> {
> 	double n;
> 	double k;
> 	double d;
> 	int t;
> 	cin >> n;
> 	t = 0;
> 	for ( k = 1;;k+=1 )
> 	{
> 		d = ( n-k*( k - 1 )/2 ) / k ;
> 		if ( d <= 0 ){ break; }
> 		if( IsInterOrNot(d) ){ t++; }
> 	}
> 	cout << t <<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