結果

問題 No.781 円周上の格子点の数え上げ
ユーザー kekuremakekurema
提出日時 2019-04-03 13:29:41
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,274 bytes
コンパイル時間 2,203 ms
コンパイル使用メモリ 100,724 KB
実行使用メモリ 26,244 KB
最終ジャッジ日時 2023-08-22 22:06:10
合計ジャッジ時間 6,685 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,680 KB
testcase_01 AC 57 ms
20,752 KB
testcase_02 AC 56 ms
20,672 KB
testcase_03 AC 57 ms
22,820 KB
testcase_04 AC 57 ms
20,676 KB
testcase_05 AC 57 ms
20,756 KB
testcase_06 AC 56 ms
20,720 KB
testcase_07 AC 58 ms
18,672 KB
testcase_08 AC 56 ms
22,732 KB
testcase_09 AC 57 ms
22,840 KB
testcase_10 AC 63 ms
20,800 KB
testcase_11 AC 81 ms
20,760 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace Code
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] values = line.Split(' ');
            int X = int.Parse(values[0]);
            int Y = int.Parse(values[1]);
            int maxSum = 0;

            for (int k = X; k <= Y; k++)
            {
                int sum = 0;
                int s = 0;
                int l = (int)Math.Sqrt(k);

                while (s <= l)
                {
                    while (s*s + l*l > k) l--;
                    if (s*s + l*l == k)
                    {
                        if (l * l == k || s == l) sum += 4;
                        else sum += 8;
                        s++;
                        l--;
                    }
                    if (s > l) break;

                    while (s*s + l*l < k) s++;
                    if (s * s + l * l == k)
                    {
                        if (l * l == k || s == l) sum += 4;
                        else sum += 8;
                        s++;
                        l--;
                    }
                }

                if (sum > maxSum) maxSum = sum;
            }

            Console.WriteLine(maxSum);
        }
    }
}
0