結果
問題 | No.176 2種類の切手 |
ユーザー | 明智重蔵 |
提出日時 | 2015-09-05 16:54:11 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,317 bytes |
コンパイル時間 | 957 ms |
コンパイル使用メモリ | 108,672 KB |
実行使用メモリ | 24,448 KB |
最終ジャッジ日時 | 2024-04-16 22:16:50 |
合計ジャッジ時間 | 4,213 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
24,448 KB |
testcase_01 | AC | 27 ms
18,944 KB |
testcase_02 | AC | 27 ms
18,944 KB |
testcase_03 | AC | 28 ms
19,072 KB |
testcase_04 | AC | 27 ms
18,944 KB |
testcase_05 | AC | 28 ms
19,072 KB |
testcase_06 | AC | 27 ms
19,072 KB |
testcase_07 | AC | 27 ms
19,072 KB |
testcase_08 | AC | 27 ms
19,072 KB |
testcase_09 | AC | 28 ms
18,816 KB |
testcase_10 | AC | 27 ms
19,072 KB |
testcase_11 | AC | 27 ms
18,944 KB |
testcase_12 | AC | 27 ms
19,072 KB |
testcase_13 | AC | 28 ms
19,072 KB |
testcase_14 | AC | 28 ms
19,072 KB |
testcase_15 | AC | 27 ms
18,944 KB |
testcase_16 | AC | 27 ms
19,328 KB |
testcase_17 | AC | 28 ms
18,816 KB |
testcase_18 | AC | 27 ms
18,816 KB |
testcase_19 | AC | 27 ms
19,072 KB |
testcase_20 | AC | 27 ms
19,072 KB |
testcase_21 | AC | 28 ms
19,200 KB |
testcase_22 | TLE | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; class Program { static string InputPattern = "Input4"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("50 80 120"); //130 //50円切手と80円切手を組み合わせて、ちょうど120円にすることはできません。 //この場合、50円切手と80円切手を1枚ずつ使って130円にするのが、 //120円以上での最少額になります。 } else if (InputPattern == "Input2") { WillReturn.Add("123 456 1"); //123 //必ずしも両方の種類の切手を使う必要はありません。 //この場合、額面の小さい123円の切手を1枚貼ることになります。 } else if (InputPattern == "Input3") { WillReturn.Add("1234 1688 10000"); //10000 //うまくすれば、ちょうど10000円にできるようです。 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List<string> InputList = GetInputList(); long[] wkArr = InputList[0].Split(' ').Select(X => long.Parse(X)).ToArray(); long wkA = wkArr[0]; long wkB = wkArr[1]; long T = wkArr[2]; //A<Bとする long A = Math.Min(wkA, wkB); long B = Math.Max(wkA, wkB); if (T % A == 0 || T % B == 0) { Console.WriteLine(T); return; } //Bを固定してAを求める long MinSumVal = long.MaxValue; for (long I = 0; ; I++) { long SumVal = B * I; long RestVal = T - SumVal; if (RestVal > 0) { long Syou = RestVal / A; if (RestVal % A > 0) Syou++; SumVal += A * Syou; if (MinSumVal > SumVal) MinSumVal = SumVal; } else { if (MinSumVal > SumVal) MinSumVal = SumVal; break; } } Console.WriteLine(MinSumVal); } }