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

数据太水了,建议增加数据。我这个暴力也A了。

Posted by tzzhwj at 2008-12-03 20:10:20 on Problem 2140
#include <stdio.h>

#define SIZE 10000001

int b[SIZE];

int main()
{
	//freopen("2140.txt","r",stdin);

	int i,j,n,tmp,cnt;

	scanf( "%d", &n );

	cnt = 0;

	b[0] = 0;
	for (i = 1 ; i <= n ; i++)
	{
		b[i] = b[i - 1] + i;
	}

	for (i = n ; i >= 1 ; i--)
	{
		for (j = i - 1 ; j >= 0 ; j--)
		{
			tmp = b[i] - b[j];

			if ( tmp == n )
			{
				cnt++;
			}
			else if ( tmp > n )
			{
				break;
			}
		}
	}

	printf( "%d\n", cnt );

	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