Cod sursa(job #3134264)
Utilizator | Stancu Adrian adistancu10 | Data | 28 mai 2023 20:23:34 |
---|---|---|---|
Problema | Farfurii | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("farfurii.in");
ofstream fout("farfurii.out");
int main()
{
long n, k;
fin >> n >> k;
long c = 1;
while ((n - c) * (n - c - 1) / 2 > k)
{
fout << c << " " ;
c++;
}
long dif = k - ((n - c) * (n - c - 1) / 2);
fout << dif + c << " ";
for (long j = n; j >= c; j--)
{
if (j != dif + c)
fout << j << " " ;
}
return 0;
}