Cod sursa(job #2347777)
| Utilizator | Data | 19 februarie 2019 08:48:36 | |
|---|---|---|---|
| Problema | Farfurii | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.56 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("farfurii.in");
ofstream g("farfurii.out");
int main()
{
long long n, k, pos;
f >> n >> k;
pos = 2;
while (((pos * (pos - 1)) >> 1) < k)
++pos;
for (int i = 1; i <= n - pos; ++i)
g << i << " ";
--pos;
long long val;
val = k - pos * (pos - 1) / 2;
val = n - pos + val;
g << val << " ";
while (pos) {
if (n == val)
--n;
g << n << " ";
--n;
--pos;
}
return 0;
}
