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 wzp_moon at 2015-09-09 16:21:01 on Problem 1455
/***********************************************************************
    Copyright (c) 2015,wangzp
    All rights no reserved.
  
    Name: 《Crazy tea party》In PEKING UNIVERSITY ACM
    ID:   PROBLEM 1455
    问题简述:  N个人围成一圈,找出最快反着做需要调换座位的次数。
 
    Date: SEP 09, 2015 
 
***********************************************************************/
#include <stdio.h>

/*偶数个人*/
int fun_even(int n)
{
	return n/2*(n/2 - 1);
}
/*奇数个人*/
int fun_odd(int n)
{
	return (n/2)*(n/2 -1)/2 + (n/2 +1)*(n/2)/2;
}
int main(void)
{
	int m,a,result;
	scanf("%d",&m);
	while(m--)
	{
		scanf("%d",&a);
		if (a%2 == 0)
		{
			result = fun_even(a);
			printf("%d\n",result);
		} 
		else
		{
			result = fun_odd(a);
			printf("%d\n",result);
		}
	}
    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