Cod sursa(job #1635679)
Utilizator | Data | 6 martie 2016 19:36:01 | |
---|---|---|---|
Problema | Farfurii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.53 kb |
#include<fstream>
using namespace std;
ifstream fin("farurii.in");
ofstream fout("farfurii.out");
int N,K;
void Read()
{
fin>>N>>K;
}
void Solve_and_Print()
{
int x = 1;
while( (x*(x-1)) / 2 < K) x++;
for(int i=1;i<=N-x;++i)
fout<<i<<" ";
K = N + K - (x*(x-1))/2;
fout<<K<<" ";
for(int i = N;i>=N-K+1;i--)
if(i!=K) fout<<i<<" ";
fout<<"\n";
}
int main()
{
Read();
Solve_and_Print();
fin.close();
fout.close();
return 0;
}