蜜蜂窝
#include<stdio.h>
int x;
int y;
int po[6][2]={0,-1,-1,0,-1,1,0,1,1,0,1,-1};
void deal(int n,int age)
{
int i;
for(i=0;i<6;i++)
{
if(n<=age)
{
x+=n*po[i][0];
y+=n*po[i][1];
return ;
}
n-=age;
x+=age*po[i][0];
y+=age*po[i][1];
}
}
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
x=0;
y=0;
n--;
int i;
for(i=1;1;i++)
{
if(n<=0)break;
n-=i*6;
}
n=-n;
x=i-1;
deal(n,i-1);
printf("%d %d\n",x,y);
}
return 0;
}
蜜蜂,输入自然数,输出左图,左右要对应
答案网上的,不好理解
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=13&problem=1123&mosmsg=Submission+received+with+ID+11322923