Cod sursa(job #2626577)
| Utilizator | Data | 6 iunie 2020 23:13:39 | |
|---|---|---|---|
| Problema | Farfurii | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Teme Pregatire ACM Unibuc 2013 | Marime | 0.53 kb |
#include <fstream>
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
int main() {
ifstream in("farfurii.in");
ofstream out("farfurii.out");
int N;
long long R;
in >> N >> R;
long long x = 1;
while (x * (x + 1) / 2 <= R)
x++;
for (int i = 1; i <= N - x - 1; i++) {
out << i << " ";
}
long long nr = N + R - x * (x + 1) / 2;
out << nr << " ";
for (int i = N; i >= N - x ; i--) {
if (i != nr)
out << i << " ";
}
}
