## D. Vasya and Triangle（数学思维）

en .感觉学弟都过了。我也没想出来。只想到了开始，没有想到怎么凑，感觉挺可惜的。

http://codeforces.com/problemset/problem/1058/D

D. Vasya and Triangle

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Vasya has got three integers n

, m and k. He'd like to find three integer points (x1,y1), (x2,y2), (x3,y3), such that 0≤x1,x2,x3≤n, 0≤y1,y2,y3≤m and the area of the triangle formed by these points is equal to nmk

.

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≤109, 2≤k≤109

).

Output

If there are no such points, print "NO".

Otherwise print "YES" in the first line. The next three lines should contain integers xi,yi

— 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).

Examples

Input

Copy

```4 3 3
```

Output

Copy

```YES
1 0
2 3
4 1
```

Input

Copy

```4 4 7
```

Output

Copy

```NO
```

Note

In the first example area of the triangle should be equal to nmk=4

. The triangle mentioned in the output is pictured below:

In the second example there is no triangle with area nmk=167

## 思路

，则无解，对于其他情况必有解存在。

``````#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;
}
``````