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

扫的,79ms……水过

Posted by OmegaColeman at 2014-08-28 20:24:30 on Problem 2140
#include <stdio.h>

int main(void)
{
	int p;
	scanf("%d", &p);
	int i = 0;
	int j = 0;
	int s = 0;
	int c = 0;
	while(1)
	{
		if (s < p)
		{
			s += j + 1;
			j = j + 1;
			if (j > p)
			{
				break;
			}
		} else if (s > p)
		{
			s -= i + 1;
			i = i + 1;
			if (i > p)
			{
				break;
			}
		} else {
			c++;
			s += j + 1;
			j = j + 1;
			if (j > p)
			{
				break;
			}
		}
	}
	printf("%d\n", c);
	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