結果

問題 No.1593 Perfect Distance
ユーザー bluemeganebluemegane
提出日時 2021-07-10 07:45:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 611 bytes
コンパイル時間 771 ms
コンパイル使用メモリ 63,124 KB
実行使用メモリ 22,768 KB
最終ジャッジ日時 2023-09-14 18:38:59
合計ジャッジ時間 2,884 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
20,736 KB
testcase_01 AC 55 ms
20,712 KB
testcase_02 AC 55 ms
20,676 KB
testcase_03 AC 55 ms
20,684 KB
testcase_04 AC 55 ms
20,708 KB
testcase_05 AC 55 ms
22,640 KB
testcase_06 AC 54 ms
20,696 KB
testcase_07 AC 55 ms
20,604 KB
testcase_08 AC 54 ms
22,740 KB
testcase_09 AC 54 ms
18,672 KB
testcase_10 AC 55 ms
20,608 KB
testcase_11 AC 55 ms
20,688 KB
testcase_12 AC 55 ms
20,692 KB
testcase_13 AC 56 ms
22,768 KB
testcase_14 AC 56 ms
22,684 KB
testcase_15 AC 57 ms
20,704 KB
testcase_16 AC 58 ms
22,660 KB
testcase_17 AC 55 ms
20,664 KB
testcase_18 AC 54 ms
20,652 KB
testcase_19 AC 56 ms
22,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using static System.Math;
using System;

public class Hello
{
    static void Main()
    {
        var n = long.Parse(Console.ReadLine().Trim());
        var n2 = n * n;
        getAns(n2);
    }
    static void getAns(long t)
    {
        var count = 0;
        for (long i = 1; i * i <= t; i++)
        {
            var s = (long)Sqrt(t - i * i);
            if (s != 0 && i * i + s * s == t) count++;
            else if (s + 1 != 0 && i * i + (s + 1) * (s + 1) == t) count++;
            else if (s - 1 != 0 && i * i + (s - 1) * (s - 1) == t) count++;
        }

        Console.WriteLine(count);
    }
}
0