题解 | 仰望水面的歪

仰望水面的歪

https://www.nowcoder.com/practice/69f00fb8b2004e039097c57b43c33b90

import java.util.*;
import java.math.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int n=sc.nextInt();
        long h=sc.nextLong();
        for(int i=0;i<n;i++){
            long x1=sc.nextLong(); 
            long y1=sc.nextLong();
            long z1=sc.nextLong();
            z1=h+h-z1;
            BigInteger x=BigInteger.valueOf(x1);
              BigInteger y=BigInteger.valueOf(y1);
                BigInteger z=BigInteger.valueOf(z1);
                BigInteger jg=x.gcd(y.gcd(z));
            System.out.printf("%d %d %d\n",x.divide(jg),y.divide(jg),z.divide(jg));
        }
    }
}

全部评论

相关推荐

每晚夜里独自颤抖:把华北改为华南再试一试,应该就没啥问题了。改完可能都不用投,别人主动联系了。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务