将折射的光线以水面为对称 反转上去 刚好z的位置应该射到2*h-z

用int后面几个例子过不去 需要改成long

#include <iostream>
#include <vector>
using namespace std;

//欧几里得算法求最大公约数
long gcd(long a, long b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int main() {
    int n, h;
    cin >> n >> h;
    while(n--) {
        long x, y, z;
        cin >> x >> y >> z;
        //将折射的光线以水面为对称 反转上去 刚好z的位置应该射到2*h-z
        long max_divisor = gcd(gcd(x, y), 2*h - z); 
        cout << x / max_divisor << " " << y / max_divisor << " " << (2*h - z) / max_divisor << endl;
    }
    return 0;
}