After so many programming questions, I feel that the code implementation is very easy as long as I find the ideas for the questions, because Baidu can be a place where the programming languages are not familiar,
However, there is no way to search for a question, unless it is ready to be searched.
This question is very easy to solve. We use the O (n2) algorithm to traverse and find the coordinate points on the non-X and Y axes + = 4 + = 2 on the x y axis.
It took 3 minutes to think about it and 2 minutes to code it.
package com.net163.question;import org.junit.Test;/** * Created by Administrator on 2016/11/11 0011. */public class CircleElegantPoint { private int number = 25; private int count = 0; @Test public void countElegantPoint(){ Integer i = Double.valueOf( Math.sqrt(number)).intValue(); for(int j = 0 ; j <= i ; j++){ //System.out.println(j); for(int g = 0 ; g <=i; g++){ if ((Math.pow(j,2)+Math.pow(g,2)) == number){ if (j==0 || g == 0){ count +=2; }else{ count +=4; } } } } System.out.println(count); }}
Netease's 2017 autumn tricks-elegance