Cod sursa(job #2617245)

Utilizator VladAlexandruAnghelache Vlad VladAlexandru Data 21 mai 2020 02:59:21
Problema Farfurii Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.4 kb
#include<bits/stdc++.h>

using namespace std;
ifstream fin("farfurii.in");
ofstream fout("farfurii.out");
int main()
{
    long int n,k;
    fin>>n>>k;

    long int x=(1+sqrt(1+8*k))/2+1;
    long int h=n-x;
    for(unsigned i=1;i<=h;i++)fout<<i<<" ";
    long int a=k+n-x*(x-1)/2;
    if(a>0)fout<<a<<" ";
    for(int i=n;i>h;i--)
        if(i!=a)
            fout<<i<<" ";

    return 0;
}