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 gardner at 2005-10-15 23:54:53 on Problem 2663
#include <stdio.h>
long tri(int n)
{
	if(n==1)return 3;
	if(n==2)return 11;
	long sum,i,temp;
	sum=1;
	temp=3;
	for(i=1;i<n;i++){
		sum=sum+temp;
		temp=3*temp+2*(sum-temp);
	}
	return temp;
}
void main()
{
	int input;
	scanf("%d",&input);
	while(input!=-1){
		if(input%2==1||input==0)printf("0\n");
		else printf("%ld\n",tri(input/2));
		scanf("%d",&input);
	}
}

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