Pagini recente » Cod sursa (job #1136503) | Cod sursa (job #2623558) | Cod sursa (job #2502519) | Cod sursa (job #889817) | Cod sursa (job #1956181)
#include <bits/stdc++.h>
using namespace std;
class Writer{
public:
Writer() {};
Writer(const char *file_name){
output_file.open(file_name,ios::out | ios::binary);
output_file.sync_with_stdio(false);
index=0;}
inline Writer &operator <<(int target){
aux=0;
n=target;
if (target<0)
sign=-1;
else
sign=1;
if (!n)
nr[aux++]='0';
for (;n;n/=10)
nr[aux++]=sign*(n%10)+'0';
if (sign==-1){
buffer[index]='-';inc();}
for(;aux;inc())
buffer[index]=nr[--aux];
return *this;}
inline Writer &operator <<(const char *target){
aux=0;
while (target[aux])
buffer[index]=target[aux++],inc();
return *this;}
~Writer(){
output_file.write(buffer,index);output_file.close();}
private:
fstream output_file;
static const int SIZE=0x200000;
int index=0,aux,n,sign;
char buffer[SIZE],nr[24];
inline void inc(){
if(++index==SIZE)
index=0,output_file.write(buffer,SIZE);}
};
int nrInversiuni(int k)
{
return k*(k-1)/2;
}
ifstream fin("farfurii.in");
Writer fout("farfurii.out");
int main()
{
int n,k,s,left,right;
fin>>n>>k;
for(s=1; nrInversiuni(s)<k; s++);
k-=s*(s-1)/2;
left=n+k;
right=n-s;
for(int i=1; i<=right; i++) fout<<i<<" ";
fout<<left<<" ";
for(; n>right; n--)
if(n!=left)
fout<<n<<" ";
}