| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
input=0->output=1In Reply To:同志们,看看我的程序,测试数据都是对的,而且我没能发现错误,请求帮助 Posted by:gardner at 2005-10-15 23:54:53 > #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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator