| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Memory: 3492K Time: 15MS......我可是用了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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator