# Codeforces 1058 D. Vasya and Triangle （思维）

## Description

Vasya has got three integers $n$, $m$ and $k$. He’d like to find three integer points $(x_1,y_1)$, $(x_2,y_2)$, $(x_3,y_3)$, such that $0≤x_1,x_2,x_3≤n$, $0≤y_1,y_2,y_3≤m$ and the area of the triangle formed by these points is equal to $\frac{nm}{k}$.

Help Vasya! Find such points (if it’s possible). If there are multiple solutions, print any of them.

## Input

The single line contains three integers $n$, $m$, $k$ $(1≤n,m≤10^9, 2≤k≤10^9)$.

## Output

If there are no such points, print “NO”.

Otherwise print “YES” in the first line. The next three lines should contain integers $x_i$,$y_i$ — coordinates of the points, one point per line. If there are multiple solutions, print any of them.

You can print each letter in any case (upper or lower).

## Note

In the first example area of the triangle should be equal to $\frac{nm}{k}=4$. The triangle mentioned in the output is pictured below:

In the second example there is no triangle with area $\frac{nm}{k}=\frac{16}{7}$.

## Examples input

4 3 3


## Examples output

YES
1 0
2 3
4 1


## AC 代码

#include <bits/stdc++.h>
#define IO                       \
ios::sync_with_stdio(false); \
cin.tie(0);                  \
cout.tie(0);
using namespace std;
typedef long long LL;
const int maxn = 1e5 + 10;

LL n, m, k;

bool solve() {
if (2LL * n * m % k != 0)
return false;
cout << "YES" << endl;
LL a, b, gc = __gcd(2LL * n, k);
if (gc == 1)
b = 2LL * m / k, a = n;
else
a = 2LL * n / gc, b = m * gc / k;
cout << "0 0" << endl;
cout << 0 << " " << b << endl;
cout << a << " " << 0 << endl;
return true;
}

int main() {
#ifdef LOCAL_IM0QIANQIAN
freopen("test.in", "r", stdin);
//    freopen("test.out", "w", stdout);
#else
IO;
#endif // LOCAL_IM0QIANQIAN

cin >> n >> m >> k;
if (!solve()) {
cout << "NO" << endl;
}
return 0;
}


### 2 只已被捕捉

• 援军 Chrome | 70.0.3538.67 Windows 10

这些是用来训练什么的呀 表示看不明白

• 千千 Chrome | 70.0.3538.67 Windows 10

训练对于特定问题使用程序来求解的思路啦~ 其实也就是算法，哈哈~