#12212: 測試執行ok , 測資點WA, 答案錯誤


alecwoo5408 (unknown)


import java.util.*;
public class me{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int x,y,z;
while(sc.hasNext()){
x = sc.nextInt();
y = sc.nextInt();
z=gcd(x,y);
System.out.println(z);
}
}
public static int gcd(int x,int y){
if(x<y){
int t=x;
x=y;
y=t;
}
int b=x%y;
if(b==0)
return y;

else
return b;
}
}

#12215: Re:測試執行ok , 測資點WA, 答案錯誤


anandrewboy70900 (ShowTsai)


 

再想想怎麼做吧..

照你的寫法

72和27的最大公因數是18???