【Codeforces 1030D】Vasya and Triangle

【链接】 我是链接,点我呀:)
【题意】

题意

【题解】

参考这篇题解:https://blog.csdn.net/mitsuha_/article/details/82825862 为什么可以保证m*gcd(2*n,k)/k是一个整数? 因为先前已经判断过 2*n*m/k是可以整除的。 显然k是被2*n和m两个数字除了之后变成1 2*n贡献的那一部分其实就是gcd(2*n,k) 那么我们显然可以直接用gcd(2*n,k)来代表2*n 所以右边肯定也是能整除的。 且<=m

【代码】

#include <bits/stdc++.h>
using namespace std;
const int N = 50;
const long long M = 15e6;

long long n,m,k;
long long x1,y1,x2,y2,x3,y3;

int main(){
    ios::sync_with_stdio(0),cin.tie(0);
    cin >> n >> m >> k;
    if ( (2*n*m)%k!=0){
        cout<<"NO"<<endl;
    }else{
        long long temp = __gcd(2*n,k);
        if (temp>1){
            x2 = 2*n/temp;
            y3 = m*temp/k;
        }else{
            temp = __gcd(2*m,k);
            x2 = n*temp/k;
            y3 = 2*m/temp;
        }
        cout<<"YES"<<endl;
        cout<<x1<<" "<<y1<<endl;
        cout<<x2<<" "<<y2<<endl;
        cout<<x3<<" "<<y3<<endl;
    }
	return 0;
}