1 条题解

  • 0
    @ 2025-8-24 21:32:11

    自动搬运

    查看原文

    来自洛谷,原作者为

    avatar EXR_FAL
    アトリは、高性能ですから!

    搬运于2025-08-24 21:32:11,当前版本为作者最后更新于2025-07-12 16:46:39,作者可能在搬运后再次修改,您可在原文处查看最新版

    自动搬运只会搬运当前题目点赞数最高的题解,您可前往洛谷题解查看更多

    以下是正文


    题解区都没有不存在格点正三角形的证明,这里给一下


    假设

    存在一个格点正三角形 ABC \triangle ABC ,其边长为 aR+ a \in \mathbb{R}^+

    正三角形的面积为:

    Area=34a2\text{Area} = \frac{\sqrt{3}}{4} a^2

    对于格点多边形,Pick 定理给出:

    Area=I+B21 \text{Area} = I + \frac{B}{2} - 1

    其中:

    • I I 为内部格点数(IN I \in \mathbb{N} ),
    • B B 为边界格点数(B3 B \geq 3 对于三角形)。

    边长 a a 是格点间距离,即:

    $$a^2 = (\Delta x)^2 + (\Delta y)^2 \quad \text{(} \Delta x, \Delta y \in \mathbb{Z} \text{)} $$

    a2N a^2 \in \mathbb{N}

    由 Pick 定理,面积必须为有理数,但:

    34a2\frac{\sqrt{3}}{4} a^2

    3 \sqrt{3} 为无理数,a2N a^2 \in \mathbb{N} ,因此仅当 a=0 a = 0 时成立,与 aR+ a \in \mathbb{R}^+ 矛盾。

    结论:在标准整数格点平面中,不存在非退化的格点正三角形。)


    格点正方形的思路题解区已经有了就不放了

    形式化的放下代码,使用了 JavaBigint 类偷懒:

    import java.io.*;
    import java.math.BigInteger;
    
    public class Main {
        public static void main(String[] args) throws IOException {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
            
            String[] input = br.readLine().split(" ");
            BigInteger n = new BigInteger(input[0]);
            BigInteger m = new BigInteger(input[1]);
            
            if (n.compareTo(m) > 0) {
                BigInteger temp = n;
                n = m;
                m = temp;
            }
            
            BigInteger c1 = n.add(BigInteger.ONE);
            BigInteger c2 = n.add(BigInteger.TWO);
            BigInteger numerator = n.multiply(c1).multiply(c2).multiply(m.multiply(BigInteger.TWO).add(BigInteger.ONE).subtract(n));
            BigInteger ans = numerator.divide(BigInteger.valueOf(12));
            
            bw.write(ans + " 0");
            bw.close();
        }
    }
    
    • 1

    信息

    ID
    912
    时间
    1000ms
    内存
    125MiB
    难度
    6
    标签
    (无)
    递交数
    0
    已通过
    0
    上传者