/*my solution to a question from Nokia interview*/
// 21 22 ……
// 20 7 8 9 10
// 19 6 1 2 11
// 18 5 4 3 12
// 17 16 15 15 13
//观察规律,设1点坐标(0,0),7点坐标(-1,-1),
//→为x正方向,↓为y正方向,编程实现输入任一坐标,输出对应数字
/**************All Rights Reserved*********************/
#include <stdio.h>
#include <math.h>
/*#define max_1(a,b) (((abs(a)>=(abs(b))?(abs(a)):(abs(b)))-1)*/
/*compute the total number within squre*/
int add_ado(int w) /*attention:w regards as positive*/
{
if(w==0)
return 1;
else
return 4*w*w+4*w+1;
}
int main()
{ int add_ado(int w);
int v1, m,n,r, k;
printf("\n\n");
scanf("%d,%d",&m,&n) ;
if(m==0&&n==0)
{ printf("1\n"); return 0;}
else if(-m==n && m>0)
{
r=add_ado(m) ; printf("%d",r); return 0;}
else
{ v1=( abs(m)>=abs(n)?abs(m):abs(n));
k=add_ado(v1-1);
if(abs(m)>=abs(n))
{ if(m>0) { printf("%d", k+m+n); return 0;}
if(m<=0) { printf("%d", k-5*m-n); return 0;}
}
if (abs(m)<abs(n))
{
if(n<0) { r= add_ado(-n)-n-m; printf("%d",r);return 0;}
if(n>0) { printf("%d", k+3*n-m); return 0;}
}
}
}