Time Limits: 1000 ms Memory Limits: 524288 KB Detailed Limits
1 #include <bits/stdc++.h> 2 using namespace std; 3 const int MAXN = 1e6+5; 4 int a[2*MAXN], n, k; 5 int main() { 6 cin>>n; 7 for (int i=1; i<=n; i++) { 8 a[i]=i; 9 } 10 for (int k=2; k<=n; k++) { 11 int t=0; 12 for (int i=k-1; i<=k+n-2; i+=k) { 13 swap (t, a[i]); 14 } 15 a[k+n-1]=t; 16 } 17 for (int i=n; i<=2*n-1; i++) { 18 cout<<a[i]<<" "; 19 } 20 return 0; 21 }