Mai intai trebuie sa te autentifici.
Cod sursa(job #2314161)
| Utilizator | Data | 7 ianuarie 2019 23:34:34 | |
|---|---|---|---|
| Problema | Arbori de intervale | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.85 kb |
#include<fstream>
#include<math.h>
#define M 100004
using namespace std;
ifstream fin("farfurii.in");
ofstream fout("farfurii.out");
using namespace std;
int v[M], N, K, i;
int main()
{
fin >> N >> K;
double x = (1 + sqrt(1 + 8 * K))/2;
if (x * (x - 1) / 2 == K)
{
for (i = 1; i < N - x; i++)
{
fout << i << " ";
}
for (i = N; i >= N - x + 1; i--)
{
fout << i << " ";
}
}
else
{
x = (int)x;
long long nr = N - ((x + 1) * x / 2 - K);
for (i = 1; i <= N - x - 1; i++)
{
fout << i << " ";
}
fout << nr << " ";
for (i = N; i >= N - x; i--)
{
fout << i << " ";
}
}
fin.close();
fout.close();
return 0;
}
