This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <cmath>
using namespace std;
struct arbore
{
int x,y;
}v[1000001];
int n,k,x,ok,z,i;
int main()
{
cin>>k;
x=sqrt(k);
while ((x+1)*(x+2)/2<=k)
x++;
z=k-x*(x+1)/2;
for (i=0; i<=x; i++)
{
if (z==i && z!=0)
{
v[i].x=i;
v[i].y=i-1;
ok++;
v[i+ok].x=i+ok;
v[i+ok].y=i-1;
i++;
if (i<=x)
{
v[i+ok].x=i+ok;
v[i+ok].y=i-1;
}
}
else
{
v[i+ok].x=i+ok;
v[i+ok].y=i-1+ok;
}
}
if (x==0)
{cout<<1<<'\n'; cout<<0<<" "<<-1;}
else {cout<<x+ok<<'\n';
for (i=0; i<=x+ok; i++)
cout<<v[i].x<<" "<<v[i].y<<'\n';}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |