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 |
Re:为什么呢?In Reply To:为什么呢? Posted by:1030202872 at 2010-08-01 22:26:27 代码如下: 为什么flag开50000000就AC,而5000000就RE呢 #include <iostream> using namespace std; int dp[500010]; char flag[50000000]={0}; int main() { int i,num; dp[0]=0; flag[0]=1; for(i=1;i<500010;i++) { if(dp[i-1]-i>=0&&flag[dp[i-1]-i]==0) { dp[i]=dp[i-1]-i; flag[dp[i]]=1; } else { dp[i]=dp[i-1]+i; flag[dp[i]]=1; } } while( cin>>num&&num!=-1) { cout<<dp[num]<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator