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
inputCopy
4 3 3
outputCopy
YES
1 0
2 3
4 1
inputCopy
4 4 7
outputCopy
NO
题意:
给你n,m,k,让你输出三个点,使得这三个点构成的三角形面积为nm/k,这三个点不能超过nm组成的长方形。
题解:
为了简化问题,我们可以将这个三角形2,变成一个长方形,那么问题就变成了让你构造一个长方形,使得这个长方形的面积是nm2/k。那么我们就先对m,k取个gcd,之后又对n2和k取个gcd,看看这个的gcd是不是k,不是的话就说明不能构造。
#include
using namespace std;
#define ll long long
int main()
{ll n,m,k;scanf("%lld%lld%lld",&n,&m,&k);ll g&#61;__gcd(m,k);ll m1&#61;m/g,n1;k/&#61;g;if(__gcd(n*2,k)!&#61;k)return 0*printf("NO\n");printf("YES\n");if((n*2)/k<&#61;n)n1&#61;(n*2)/k;elsem1&#61;m1*2,n1&#61;n/k;printf("0 0\n");printf("%lld 0\n",n1);printf("%lld %lld\n",n1,m1);return 0;
}