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

第一百题,木有看过discuss,纯手工制作,随便写写吧

Posted by TSERROF at 2012-09-06 19:39:20 on Problem 1455
#include <cstdio>
int f(int n){return n*(n-1)/2;}
int main()
{
	int T;
	scanf("%d",&T);
	while(T--)
	{
		int n;
		scanf("%d",&n);
		int ans=n-2;
		if(n%2==0)ans=ans+f((n-2)/2)*2;		
		else ans=ans+f((n-3)/2)+f((n-3)/2+1);
		printf("%d\n",ans);
	}
	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