Mai intai trebuie sa te autentifici.
Cod sursa(job #1204239)
| Utilizator | Data | 2 iulie 2014 14:07:03 | |
|---|---|---|---|
| Problema | Farfurii | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <fstream>
using namespace std;
long long n,m,tot;
int sol[100005],lista[100005],nrl;
int main()
{
ifstream in ("farfurii.in");
ofstream out ("farfurii.out");
in>>n>>m;
tot=(n*(n-1))/2;
tot-=m;
int i=1; nrl=0;
while (tot>0)
{
while (tot<n-i) ++i;
++nrl; lista[nrl]=i; sol[i]=1; tot=tot-n+i;
++i;
}
for (int i=1;i<=nrl;++i) out<<lista[i]<<" ";
for (int i=n;i>0;--i) if (sol[i]==0) out<<i<<" ";
in.close();
out.close();
return 0;
}
