主页的一道编程题。

首页的一道编程题。。。
首页那些题看了好多好复杂的,找到个简单的。。。提交上去还说错的。。。整个人生都灰暗了,这题难么?错哪儿了,望大神指正。

 题目详情

给定整数区间[A,B]问其中有多少个完全平方数。

输入格式:

多组数据,包含两个正整数A,B 1<=A<=B<=2000000000。

输出格式:1 2  1 4 3  5
输出格式:1
                 2
                 1

每组数据输出一行包含一个整数,表示闭区间[A,B]中包含的完全平方数的个数

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class XiaobaishuShidu {
 public static void main(String[] args) {
 calcount();


                  }
   static void calcount(){
  System.out.println("请输入偶数个数据满足,第k个数 k<=k+1(k=1,3,5,7,9···),空格隔开");
Scanner input =  new Scanner(System.in);
String []temp = input.nextLine().split(" ");
if(temp.length%2==0){

for (int i = 0; i <= temp.length-2; i+=2) {

int m = Integer.parseInt(temp[i]);
int n = Integer.parseInt(temp[i+1]);
if(n > m){
int count;
double f1,f2;
f1 = Math.sqrt(m);
        f2 = Math.sqrt(n);
if(f1%1==0){
count =(int)f2 - (int) f1 + 1;
}else{
 count = ((int) f2 - (int)f1);
}
System.out.println(count);
}else{
System.out.println("数据不合法,请重新输入");
calcount();
}
}
}else{
System.out.println("数据不合法,请重新输入");
calcount();
}

  }
 
}

------解决方案--------------------
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;


public class Test
{
    public static void main(String[] args) throws IOException
    {
        InputStream is = new BufferedInputStream(System.in);
        byte[] be = new byte[1024];
        int i ;
        while(true){
            while((i=is.read(be))>-1){
                String s = new String(be,0,i);
                String[] ss = s.split(",");
                
                double a = Double.parseDouble(ss[0]);
                double b = Double.parseDouble(ss[1]);
                
                double a1 = Math.ceil(Math.sqrt(a));
                double b1 = Math.floor(Math.sqrt(b));
                
                int ii = (int)(b1-a1)+1;
                System.out.println("有"+ii+"个平方数。");
            }
        }
    }
    
}

比较简陋的代码,功能实现了