Pagini recente » Cod sursa (job #545846) | Cod sursa (job #772517) | Cod sursa (job #852844) | Cod sursa (job #2472832) | Cod sursa (job #1083226)
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
long long x, i, val, n, k;
ifstream f("farfurii.in");
ofstream g("farfurii.out");
long long farf(long long k) {
double x;
x = (1 + sqrt(1+8*k))/2;
if (x == (long long)x)
return x;
else return (long long)x + 1;
}
int main() {
f>>n>>k;
x=farf(k);
val=x*(x-1)/2;
for (i=1; i<=n-x; ++i)
g<<i<<' ';
g<<n-(val-k)<<' ';
for (i=n; i>n-x; --i)
if (i!=n+k-val)
g<<i<<' ';
return 0;
}