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 201501060326 at 2016-02-22 20:47:25 on Problem 1844
#include <stdio.h>
int main()
{
    int s,n,d;
    while(scanf("%d",&s)!=EOF)
    {
        for(n=1;; n++)
        {
            if(n*(n+1)/2==s)
            {
                printf("%d\n",n);
                break;
            }
            else if(n*(n+1)/2>s)
            {
                d=n*(n+1)/2-s;
                if(d%2!=0)
                    continue;
                else
                    d/=2;
                if(d>=1)
                    printf("%d\n",n);
                break;
            }
        }
    }
    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