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 0912070002 at 2010-09-17 00:13:22 on Problem 2140
#include <stdio.h>
#include <math.h>

int main(void)
{
	int N;
	int i;
	int nums = 0,temp;

	scanf("%d",&N);
	for (i = 1; i <= N; i++)
	{
		temp = (int)(((1 - 2*i) + sqrt((double)(4*i*i-4*i+1+8*N)))/2.0);
		
		if(temp >= 1) {
			if (N == (temp*i + temp*(temp-1)/2))
			{
				nums++;
			}
			else if (N == ((temp+1)*i + temp*(temp+1)/2))
			{
				nums++;
			}
		}
	}
	printf("%d\n",nums);
	
	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