結果
問題 |
No.1059 素敵な集合
|
ユーザー |
|
提出日時 | 2024-01-22 14:11:48 |
言語 | C# (.NET 8.0.404) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,434 bytes |
コンパイル時間 | 7,904 ms |
コンパイル使用メモリ | 168,708 KB |
実行使用メモリ | 189,060 KB |
最終ジャッジ日時 | 2024-09-28 06:25:04 |
合計ジャッジ時間 | 14,403 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 RE * 2 |
other | WA * 4 RE * 15 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (99 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
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[,] costs = new int[R - L + 1, R - L + 1]; for (int i = 0; i < costs.GetLength(0); i++) { for (int j = 0; j < costs.GetLength(1); j++) { costs[i, j] = S[i] % S[j]; } } // 最小コストを求める int minCost = int.MaxValue; for (int i = 0; i < costs.GetLength(0); i++) { for (int j = 0; j < costs.GetLength(1); j++) { // 最小コストを更新する if (costs[i, j] < minCost) { minCost = costs[i, j]; } } } // 結果を出力する //Console.WriteLine("最小コストは {0} です。", minCost); Console.WriteLine(minCost); } }