原题链接
- 题意:在 (1 leqslant n leqslant 1e9, 1leqslant m leqslant 1e9, 1 < k leqslant 1e9) 的情况下,构造出 (1leqslant x leqslant n, 1 leqslant
yleqslant m) 同时三个点构成的三角形面积等于 (frac{n imes m}{k})。
- 题解:主要是当在抽象成 (x imes y = frac{n imes m}{2 imes k}) 的时候,只注意了枚举终点,但是最关键的是起点也可以,因为这是有两个限制,就是 (x) 和 (y) 都得同时满足条件,所以当 (x) 从 (1) 开始会令 (y) 不满足,遍历过多。
- 代码:
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll n, m, k;
ll N;
bool check(ll x, ll y) {
if (x > N || y > m)return 0;
return 1;
}
void solve() {
scanf("%lld%lld%lld", &n, &m, &k);
N = n;
n = 2 * n * m;
if (n % k != 0) {
cout << "NO
";
return;
}
n /= k;
for (ll x = max(1ll, n/(max(N,m))); x * x <= n; x ++) {
ll y = n/(x);
if (n % x == 0 ) {
if (!check(x, y)) {
swap(x, y);
if (check(x, y)) {
cout << "YES
";
cout << "0 0
";
cout << 0 << " " << y << endl;
cout << x << " " << 0 << endl;
return;
} else swap(x, y);
} else {
cout << "YES
";
cout << "0 0
";
cout << 0 << " " << y << endl;
cout << x << " " << 0 << endl;
return;
}
}
}
cout << "NO
";
}
int main() {
#ifndef ONLINE_JUDGE
freopen("in.in", "r", stdin);
freopen("out.out", "w", stdout);
#endif
ll n = 1;
while (n--) {
solve();
}
return 0;
}