Pagini recente » Cod sursa (job #2138375) | Cod sursa (job #2439377) | Cod sursa (job #1609519) | Cod sursa (job #741724) | Cod sursa (job #716428)
Cod sursa(job #716428)
#include<iostream>
#include<fstream>
using namespace std;
ifstream in("farfurii.in");
ofstream out("farfurii.out");
long long n,k,mm;
int main() {
long long i,p;
in >> n >> k;
for(i=1;i<=n;++i) {
p = n-i;
if(p*(p-1)/2 < k) {
mm = k - (p-1)*p/2 + i;
out << mm << " ";
break;
}
out << i << " ";
}
p = n-i+1;
for(i=0;i!=p;++i) {
if(n-i!=mm)
out << n-i << " ";
}
return 0;
}