标签:
找规律。
#include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath> #define N 10005 #define ll long long using namespace std; ll n,t,x,y; ll fx[10]={1,-1,-2,-1,1,2,1}; ll fy[10]={2,2,0,-2,-2,0,2}; int main(){ cin>>n; if(n==0){ puts("0 0"); return 0; } t=sqrt(n/3); while(t*(t+1)*3>=n)t--; x=t*2; y=0; n-=t*(t+1)*3; if(n){ x+=fx[0]; y+=fy[0]; n--; } ll s=min(t,n); x+=fx[1]*s; y+=fy[1]*s; n-=s; ll d=2; ll dx=0,dy=0; t++; while(n>=t){ dx+=fx[d]; dy+=fy[d]; d++; printf("%lld ",d); n-=t; } x+=fx[d]*n; y+=fy[d]*n; cout<<x+dx*t<<" "<<y+dy*t<<endl; }
标签:
原文地址:http://www.cnblogs.com/flipped/p/5742564.html