Pagini recente » Cod sursa (job #1022633) | Cod sursa (job #543001) | Cod sursa (job #391933) | Cod sursa (job #3138351) | Cod sursa (job #1298821)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("multimi2.in");
ofstream g ("multimi2.out");
const int NMAX = 1000000 + 1;
int n;
bool suma[NMAX];
void rezolva() {
long long s = 1LL * n * (n + 1) / 2 / 2;
int nr = 0;
for (int i = n; i >= 1; i--)
if (s >= i) {
s -= i;
nr++;
suma[i] = true;
}
g << (1LL * n * (n + 1) / 2 % 2) << '\n';
g << nr << '\n';
for (int i = 1; i <= n; i++)
if (suma[i]) g << i << '\n';
g << n - nr << '\n';
for (int i = 1; i <= n; i++)
if (!suma[i]) g << i << '\n';
}
int main() {
f >> n;
rezolva();
return 0;
}