兩個坑
1. 輸入的m,n 並不一定是按順序排列
2. Math.pow 返回一個double 類型,要進行強制類型轉換
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner sr=new Scanner(System.in);
while(sr.hasNext()) {
int start = sr.nextInt();
int end = sr.nextInt();
if(end <= start){
int num = end;
end = start;
start = num;
}
long pow2 = 0;
long pow3 = 0;
for(int i = start; i <= end; i++){
if(Judge(i)){
pow2 = pow2 + (long)Math.pow(i,2);
}
else{
pow3 = pow3 + (long)Math.pow(i,3);
}
}
System.out.println(pow2 + " " + pow3);
}
}
public static boolean Judge(int value){
if(value % 2 == 0){
return true;
}else{
return false;
}
}
}