Cod sursa(job #2904078)
Utilizator | Dirva Nicolae NicuDirva | Data | 17 mai 2022 22:11:09 |
---|---|---|---|
Problema | Farfurii | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Teme Pregatire ACM Unibuc 2013 | Marime | 0.46 kb |
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
ifstream fin ("farfurii.in");
ofstream fout("farfurii.out");
long n, x, y, lg;
int main()
{
fin>>n>>x;
while(lg*(lg+1)>>1 <= x)
lg++;
for(int i = 1; i <= n-lg - 1; i++)
fout<<i<<" ";
y = lg * (lg+1) / 2 - x;
fout<<n - y <<" ";
for(int i = n; i >= n - lg; i--)
if(i != n - y)
fout<<i<<" ";
fin.close();
fout.close();
return 0;
}