Cod sursa(job #2752166)
| Utilizator | Data | 16 mai 2021 22:25:24 | |
|---|---|---|---|
| Problema | Farfurii | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
#include <fstream>
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
ifstream fin("farfurii.in");
ofstream fout("farfurii.out");
int main() {
int N;
long long R;
fin >> N >> R;
long long x = 1;
while (x * (x + 1) / 2 <= R)
x++;
for (int i = 1; i <= N - x - 1; i++) {
fout << i << " ";
}
long long nr = N + R - x * (x + 1) / 2;
fout << nr << " ";
for (int i = N; i >= N - x ; i--) {
if (i != nr)
fout << i << " ";
}
}
