解题思路:
从部分出发寻找整体的规律,本题先找到第一象限的规律再推导出其他象限的规律
import java.util.Scanner;
public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);long x = sc.nextInt();long y = sc.nextInt();long x_ ,y_,num = 0;if(x==0 && y==0) num=0;else {x_ =Math.abs(x);y_ =Math.abs(y);long t=Math.max(x_, y_);if(x<=0 && y>=0) {//第四象限num=4*t*t-2*t-x_+y_;}else if(x>0 && y>0) {//第一象限num=4*t*t+x_-y_;}else if(x>=0 && y<=0) {//第二象限num=(4*t+2)*t+y_-x_;}else if(x<0 && y<0) {//第三象限num=4*t*t-3*t-(t-1)+(x_-1)-y_;}}System.out.print(num);}}