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

Re:帮我看看错哪儿了吧,谢谢了!这题好像很简单,花不了您多少时间的!

Posted by dancia at 2005-04-04 20:31:14 on Problem 1844
In Reply To:Re:帮我看看错哪儿了吧,谢谢了!这题好像很简单,花不了您多少时间的! Posted by:cpp050800448280 at 2005-04-03 10:26:08
my code:

#include <stdio.h>
#include <math.h>
#define sum(x) x*(x+1)/2

main()
{
  int i,n,s;
  scanf("%d",&s);
  n=(1+(int)sqrt(-1+8*s))/2;
  for(i=n;;i++)
    if(sum(i-1)<s )
      break;
 ((sum(i)-s)%2)?((i%2)?printf("%d",i+2):printf("%d",i+1)):printf("%d",i);
 return 0;         
}

> if((sum-m)%2) t=i+2 不对
> 要一位一位加

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