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 _Belove_Test at 2016-01-04 01:20:20 on Problem 3705
#include <stdio.h>

void print(int n)
{

	int start=n/2;
	for(int i=1;i<=n/2;i++,start--){
		printf("%d %d %d\n",start,2,n-i-1);
	}
	printf("%d %d %d\n",
			(n&1)? 2:1,n/2,(n+1)/2);
}

int main()
{
	int n;
	while(scanf("%d",&n)!=EOF){
		if(n==1){
			puts("0");
			continue;
		}
		if(n==2){
			puts("1");
			puts("1 1 1");
			continue;
		}
		printf("%d\n",n/2+1);
		print(n);
	}
	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