Pagini recente » Cod sursa (job #1680304) | Cod sursa (job #756939) | Cod sursa (job #566534) | Cod sursa (job #261825) | Cod sursa (job #2940313)
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int, int>
using ll = long long;
using namespace std;
/*******************************/
// INPUT / OUTPUT
ifstream f("farfurii.in");
ofstream g("farfurii.out");
/*******************************/
/// GLOBAL DECLARATIONS
ll N, K;
ll cnt;
vector <int> sol;
/*******************************/
/// FUNCTIONS
void ReadInput();
void Solution();
void Output();
/*******************************/
///-------------------------------------
inline void ReadInput()
{
f >> N >> K;
}
///-------------------------------------
inline void Solution()
{
while ((N - cnt - 1) * (N - cnt - 2) / 2 >= K)
cnt ++;
for (int i = 1 ; i <= cnt ; ++ i)
sol.push_back(i);
int x = (N - cnt) * (N - cnt - 1) / 2 - K, num = N - x;
if (num > cnt) sol.push_back(num);
for (int i = N ; i > cnt ; -- i)
if (i != num) sol.push_back(i);
}
///-------------------------------------
inline void Output()
{
for (auto x: sol)
g << x << " ";
}
///-------------------------------------
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ReadInput();
Solution();
Output();
return 0;
}