Cod sursa(job #3134122)
Utilizator | Data | 28 mai 2023 15:40:00 | |
---|---|---|---|
Problema | Farfurii | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include <fstream>
#include <iostream>
using namespace std;
ifstream f("farfurii.in");
ofstream g("farfurii.out");
int main()
{
long N, K;
f >> N >> K;
long cnt = 1;
while ((N - cnt) * (N - cnt - 1) / 2 > K)
{
g << cnt ;
cnt++;
}
long dif = K - ((N - cnt) * (N - cnt - 1) / 2);
g << dif+cnt ;
for (long j = N; j >= cnt; j--)
{
if (j != dif + cnt)
g << j ;
}
return 0;
}