結果

問題 No.1059 素敵な集合
ユーザー Kiyoshi MorohashiKiyoshi Morohashi
提出日時 2024-01-22 14:04:30
言語 C#
(.NET 8.0.203)
結果
TLE  
実行時間 -
コード長 1,134 bytes
コンパイル時間 13,877 ms
コンパイル使用メモリ 158,768 KB
実行使用メモリ 45,772 KB
最終ジャッジ日時 2024-01-22 14:04:49
合計ジャッジ時間 13,035 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
34,468 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (126 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

using System;

class Program
{
    static void Main(string[] args)
    {
        // L と R を入力する
        //Console.WriteLine("L を入力してください:");
        string[] L_R = Console.ReadLine().Split(' ');
        int L = int.Parse(L_R[0]);
        //Console.WriteLine("R を入力してください:");
        int R = int.Parse(L_R[1]);

        // 集合 S を作成する
        int[] S = new int[R - L + 1];
        for (int i = 0; i < S.Length; i++)
        {
            S[i] = i + L;
        }

        // 最小コストを求める
        int minCost = int.MaxValue;
        for (int i = 0; i < S.Length; i++)
        {
            for (int j = i + 1; j < S.Length; j++)
            {
                // コストを計算する
                int cost = S[i] % S[j];

                // 最小コストを更新する
                if (cost < minCost)
                {
                    minCost = cost;
                }
            }
        }

        // 結果を出力する
        //Console.WriteLine("最小コストは {0} です。", minCost);
        Console.WriteLine(minCost);
    }
}
0