Cod sursa(job #2784981)

Utilizator Andrei_TudorAndrei Tudor Andrei_Tudor Data 17 octombrie 2021 19:37:12
Problema Farfurii Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.48 kb
#include <fstream>
using namespace std;
ifstream cin("farfurii.in");
ofstream cout("farfurii.out");
int main () {
    long long n, k, m = 1;
    cin >> n >> k;
    while (m * (m + 1) / 2 <= k) {
        m ++;
    }
    for(int i = 1; i < n - m; i ++){
        cout << i << " ";
    }
    long long x = n + k - m * (m + 1) / 2;
    cout << x << " ";
    for(int i = n; i > n - m - 1; i --){
        if(i != x){
            cout << i << " ";
        }
    }
    return 0;
}