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 harry1990 at 2013-10-15 12:07:04 on Problem 2081
#include <stdio.h>

int main()
{
    int k,m,a[500000];
    char b[3012501]={0};
    k=0;

            a[0]=0;
            b[0]=-1;
        for(m=1;m<=500000;m++){
            a[m]=a[m-1]-m;
            if(a[m]<0||b[a[m]]==-1)
                a[m]=a[m-1]+m;
            b[a[m]]=-1;
        }
        while(k!=-1){
                scanf("%d",&k);
                if(k!=-1) printf("%d\n",a[k]);
        }
    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