JAVA请大佬帮忙看看
查看原帖
JAVA请大佬帮忙看看
498348
zyhloveyou楼主2022/11/23 20:38
//P1482 Cantor表(升级版)
import  java.util.*;
/**
思路是 先求积 在求gcd
AC了 两个
*/
public class Main {
  public static int gcd(int a,int b){
       return a%b==0? b : gcd(b,a%b);
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.next();
        String str2 = scanner.next();
        int x = str1.charAt(0)-'0';
        int y = str1.charAt(2)-'0';
        int x1 = str2.charAt(0)-'0';
        int y2 = str2.charAt(2)-'0';
        int a1 = x*x1;
        int b2 = y*y2;
        int gcd = gcd(a1,b2);
        System.out.println(b2/gcd+" "+a1/gcd);
        
        //这里的输出换了位置之后只AC 1个

    }
}

2022/11/23 20:38
加载中...