Cod sursa(job #1899721)
| Utilizator | Data | 2 martie 2017 21:46:43 | |
|---|---|---|---|
| Problema | Farfurii | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.69 kb |
#include <fstream>
#define nmax 100001
using namespace std;
ifstream fin("farfurii.in");
ofstream fout("farfurii.out");
int n,k,a[nmax],z;
long long h;
inline long long suma(int h)
{
return h*(h-1)/2;
}
int main()
{
int i;
fin>>n>>k;
z=n;
while(k>suma(h))
h++;
h--;
if(h==k)
{
for(i=1;i<=n-h;i++)
fout<<i<<' ';
for(i=n;i>n-h;i--)
fout<<i<<' ';
}
else
{
for(i=1;i<n-h;i++)
fout<<i<<' ';
fout<<h+1<<' ';
for(i=n;i>=n-h;i--)
if(i!=h+1)
fout<<i<<' ';
}
fin.close();
fout.close();
return 0;
}
