1234 • 18天前
using namespace std; const int MAXN=1000000; bool book[MAXN]={false}; int main(){ int n; cin>>n; vectora={1}; book [1]=true; for(int k=2;k<=n;++k) { int g=a.back()-k; if(g<=0||book[g])g=a.back()+k; a.push_back(g); book[g]=true; } sort (a.begin(),a.end()); for (int x:a) cout<<x<< " "; return 0; }
评论:
请先登录,才能进行评论