1 #include <iostream> 2 #define MAXN 500005 3 using namespace std; 4 5 //unsigned _m[MAXN]; 6 bool mark[MAXN*10]; 7 8 int main() 9 { 10 //freopen("acm.acm","r",stdin); 11 // _m[0] = 0; 12 13 int i; 14 int num; 15 16 int p_1; 17 int p_2; 18 19 while(cin>>num,num != -1) 20 { 21 p_1 = p_2 = 0; 22 memset(mark,0,sizeof(mark)); 23 for(i = 1; i <= num; ++ i) 24 { 25 26 if(p_1 - i > 0 && !mark[p_1 - i]) 27 { 28 p_2 = p_1 - i; 29 mark[p_2] = true; 30 } 31 else 32 { 33 p_2 = p_1 + i; 34 mark[p_2] = true; 35 } 36 p_1 = p_2; 37 } 38 cout<<p_2<<endl; 39 } 40 }
时间: 2024-11-04 01:32:29