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

机子上跑不过,都能AC!!!!!

Posted by THREEGIRL at 2011-06-06 10:13:33 on Problem 2081
#include <iostream>
using namespace std;

int main()
{
    int a[500001] = {0};
    a[0] = 0;
    bool b[4000000] = {false};
    int temp;
    for( int i = 1; i <= 500000; i++ )
    {
        temp = a[i-1] - i;
        if( temp <= 0 || b[temp] == true )
            a[i] = a[i-1] + i;
        else
            a[i] = a[i-1] - i;
        b[a[i]] = true;
    }
    int k;
    while( scanf( "%d", &k ) )
    {
        if( k == -1 )
            break;
        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