Pagini recente » Cod sursa (job #1905973) | Cod sursa (job #1684287) | Cod sursa (job #1671175) | Cod sursa (job #1626268) | Cod sursa (job #2909927)
#include <fstream>
#include <set>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
oset<int> s;
int main() {
ifstream fin("order.in");
ofstream fout("order.out");
int n;
fin >> n;
for (int i = 1; i <= n; i++) {
s.insert(i);
}
int index = -1;
while (n > 0) {
if (index == -1) {
index = 1;
} else {
index = (2 * index) % n;
}
auto it = s.find_by_order(index);
fout << (*it) << " ";
s.erase(it);
n--;
}
return 0;
}