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

Y WA?

Posted by zouyu9631 at 2006-08-12 07:56:01 on Problem 1809
把点分成四种类型,分别统计数目,结果应该是n个点中取3个的方法书减去不符合要求的构成。
大牛们能否百忙之中告知是哪儿错了?


//pku1809
//

#include<stdio.h>

int main()
{
//	freopen("in.txt", "r", stdin);
//	freopen("out.txt", "w", stdout);

	int tt, ii, i;
	__int64 n;
	int x, y;
	int a, b, c, d;
	scanf("%d", &tt);
	for(ii = 1; ii <= tt; ii++)
	{
		a = b = c = d = 0;
		scanf("%I64d", &n);
		for(i = 0; i < n; i++)
		{
			scanf("%d%d", &x, &y);
			if(x%2!=0)
			{
				if(y%2!=0)
					d++;
				else
					c++;
			}
			else
			{
				if(y%2)
					b++;
				else
					a++;
			}
		}
		__int64 res = n*(n-1)*(n-2)/6;
		res -= (a*b*c+a*b*d+a*c*d+b*c*d);
		printf("Scenario #%d:\n", ii);
		printf("%I64d\n\n", res);
	}
	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