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

Memory: 3492K Time: 15MS

Posted by huyue at 2007-10-27 20:06:50 on Problem 2081
......我可是用了iostream啊.......
bool真是好东西,以后多用用
Source Code

Problem: 2081  User: huyue 
Memory: 3492K  Time: 15MS 
Language: G++  Result: Accepted 

Source Code 
#include<iostream.h>
int n,m,i,j,k,a[500000],z[10000],max;
bool b[3012500];
int main()
{
  z[0]=0;
  do
  {
    cin>>z[++z[0]];
    if(z[z[0]]>max)max=z[z[0]];
  }
  while(z[z[0]]!=-1);
  a[1]=0;b[0]=1;
  for(i=1;i<=max;i++)
  {
    a[i]=a[i-1]-i;
    if(!(a[i]>0&&!b[a[i]]))
    {
      a[i]=a[i-1]+i;
    }
    b[a[i]]=1;
  }
  for(i=1;i<=z[0]-1;i++)
  cout<<a[z[i]]<<endl;
//  system("PAUSE");
}


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