AT_agc036_a [AGC036A] Triangle 题解

· · 题解

解题思路

这就是一道数学题好吧,本蒟蒻刚好学到。

一个顶点在 (0,0) 的三角形,它的面积就是 \frac12(x1 \times y2-x1 \times x2)。

我们的坐标要尽可能小,所以我们可以把 x1 与 y2 取值为 \sqrt s。

CODE:

#include <stdio.h>
#include <math.h>
typedef long long ll;
int main() {
    ll s;
    scanf("%lld", &s);
    ll x1, y2;
    x1 = y2 = ceil(sqrt(s));
    ll x2 = x1 * y2 - s;
    printf("0 0 %lld %lld 1 %lld", x1, x2, y2);
    return 0;
}