#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
wrong number of pairs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
wrong number of pairs |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
212 KB |
wrong number of pairs |
3 |
Halted |
0 ms |
0 KB |
- |