Cod sursa(job #2904007)
Utilizator | Tindeche Alexandru Tindeche | Data | 17 mai 2022 21:53:15 |
---|---|---|---|
Problema | Farfurii | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream fin("farfurii.in");
ofstream fout("farfurii.out");
int main ()
{
long long n, k, x = 1, i;
fin >> n >> k;
while(x * (x + 1) / 2 <= k)
++x;
for (i = 1; i <= n - x - 1; i++)
fout << i << ' ';
fout << n + k - x * (x + 1) / 2 << ' ';
for(i = n; i >= n - x; i--)
if(i != n + k - x * (x + 1) / 2)
fout << i << ' ';
return 0;
}