Cod sursa(job #2347753)

Utilizator GhSamuelGherasim Teodor-Samuel GhSamuel Data 19 februarie 2019 08:22:24
Problema Farfurii Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.54 kb
#include <bits/stdc++.h>

using namespace std;
ifstream f("farfurii.in");
ofstream g("farfurii.out");

int main()
{
    long long n, k, pos;
    f >> n >> k;

    pos = 2;
    while ((pos * (pos - 1) >> 2) > k)
        ++pos;

    for (int i = 1; i <= pos; ++i)
        g << i << " ";

    long long val;
    val = (n - 1) * (n - 2) >> 2;
    g << val - 2 << " ";

    pos++;
    while (pos) {
        if (n == val - 2)
            --n;
        g << n << " ";
        --n;
        --pos;
    }
    g << n;
    return 0;
}