Cod sursa(job #3133845)
Utilizator | Data | 27 mai 2023 10:39:59 | |
---|---|---|---|
Problema | Farfurii | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.47 kb |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
//ifstream fin("nr.txt");
ofstream fout("farfurii.out");
ifstream fin("farfurii.in");
long long n, k, x = 1;
fin>>n>>k;
while(k > x*(x-1)/2)
x++;
for(long long i = 1; i <= n-x; i++){
fout<<i<<" ";
}
fout<<n - (x*(x-1)/2 - k)<<" ";
for(long long i = n; i > n - x; i--)
if(i != x)
fout<<i<<" ";
return 0;
}