結果

問題 No.1593 Perfect Distance
ユーザー bluemeganebluemegane
提出日時 2021-07-10 07:51:10
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 766 ms
コンパイル使用メモリ 65,292 KB
実行使用メモリ 22,676 KB
最終ジャッジ日時 2023-09-14 18:39:12
合計ジャッジ時間 2,853 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
20,672 KB
testcase_01 AC 56 ms
22,656 KB
testcase_02 AC 56 ms
22,676 KB
testcase_03 AC 55 ms
22,596 KB
testcase_04 AC 55 ms
20,652 KB
testcase_05 AC 55 ms
20,700 KB
testcase_06 AC 55 ms
20,540 KB
testcase_07 AC 55 ms
20,660 KB
testcase_08 AC 55 ms
20,620 KB
testcase_09 AC 55 ms
20,612 KB
testcase_10 AC 57 ms
22,668 KB
testcase_11 AC 56 ms
20,656 KB
testcase_12 AC 55 ms
18,616 KB
testcase_13 AC 56 ms
22,668 KB
testcase_14 AC 57 ms
20,648 KB
testcase_15 AC 57 ms
20,616 KB
testcase_16 AC 58 ms
20,644 KB
testcase_17 AC 56 ms
20,648 KB
testcase_18 AC 55 ms
22,664 KB
testcase_19 AC 56 ms
22,648 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++;
        }
        Console.WriteLine(count);
    }
}
0