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 dong930 at 2007-07-18 21:15:11 on Problem 1032
In Reply To:通过的代码,看吧,很简单 Posted by:hahaxiao at 2005-09-03 09:08:00
#include<stdio.h>
main()
{
 int n,k,j,i,t,d,s=0;
 scanf("%d",&n);
 for(i=2;i<=45;i++)
   {
      s+=i;
      if(s>=n) break;
   }
   t=n-s+i;
 if(t==i)
   {
    for(j=2;j<=i-1;j++)
      printf("%d ",j+1);
     printf("%d",j+2);
   }
 else
 {
 for(j=2;j<i-t;j++)
   printf("%d ",j);
 for(k=1;k<t;k++,j++)
   printf("%d ",j+1);
 printf("%d",j+1);
  }
   
}

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