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 nn, mm and kk. He'd like to find three integer points (x1,y1)(x1,y1), (x2,y2)(x2,y2), (x3,y3)(x3,y3), such that 0≤x1,x2,x3≤n0≤x1,x2,x3≤n, 0≤y1,y2,y3≤m0≤y1,y2,y3≤m and the area of the triangle formed by these points is equal to nmknmk.
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 nn, mm, kk (1≤n,m≤1091≤n,m≤109, 2≤k≤1092≤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,yixi,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=4nmk=4. The triangle mentioned in the output is pictured below:
In the second example there is no triangle with area nmk=167nmk=167.
点我传送
给出n、m、k.求一个三角形使它的面积等于n*m/k 并且这个三角形的三个顶点所在的坐标为整数点,且顶点满足0<=x<=n,0<=y<=m.询问是否存在这样的三角形。若存在则输出任意一种符合情况的三个顶点。
想解决这个问题,需要了解皮克定理。
把面积n*m/k 乘以二,变成S=2*n*m/k 。那么这个S必然是一个整数。若把这个三角形的一个顶点设在(0,0),那么存在这么一个直角三角形(a,0)、(0,b).使得a*b=2*n*m/k.
问题就变成了寻找范围在[0,n]之间的a和在[0,m]之间的b。
#include
#include
#include
#include