結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー | nanophoto12 |
提出日時 | 2015-12-09 00:31:04 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,928 bytes |
コンパイル時間 | 1,070 ms |
コンパイル使用メモリ | 108,544 KB |
実行使用メモリ | 19,456 KB |
最終ジャッジ日時 | 2024-09-14 20:36:32 |
合計ジャッジ時間 | 3,146 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
19,328 KB |
testcase_01 | AC | 32 ms
19,328 KB |
testcase_02 | AC | 29 ms
19,072 KB |
testcase_03 | AC | 31 ms
19,200 KB |
testcase_04 | AC | 32 ms
19,200 KB |
testcase_05 | WA | - |
testcase_06 | AC | 31 ms
19,200 KB |
testcase_07 | WA | - |
testcase_08 | AC | 32 ms
19,456 KB |
testcase_09 | AC | 30 ms
19,200 KB |
testcase_10 | AC | 31 ms
19,328 KB |
testcase_11 | WA | - |
testcase_12 | AC | 32 ms
19,072 KB |
testcase_13 | AC | 32 ms
19,328 KB |
testcase_14 | AC | 32 ms
19,200 KB |
testcase_15 | AC | 32 ms
19,328 KB |
testcase_16 | AC | 31 ms
19,200 KB |
testcase_17 | AC | 31 ms
19,328 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 32 ms
19,328 KB |
testcase_24 | AC | 31 ms
19,200 KB |
testcase_25 | AC | 31 ms
19,200 KB |
testcase_26 | AC | 32 ms
19,328 KB |
testcase_27 | AC | 32 ms
19,200 KB |
testcase_28 | AC | 32 ms
19,200 KB |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
コンパイルメッセージ
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; using System.Text; namespace No316t { class MainClass { private static long Pow(long value, long pow){ long result = 1; for (int i = 0; i < pow; i++) { result *= value; } return result; } private static long Multiply(Dictionary<long, int> first, Dictionary<long, int> second){ long value = 1; foreach (var keyValue in first) { int mul = keyValue.Value; if(second.ContainsKey(keyValue.Key)){ mul = Math.Max(mul, second[keyValue.Key]); second.Remove (keyValue.Key); } value *= Pow (keyValue.Key, mul); } foreach (var keyValue in second) { value *= Pow (keyValue.Key, keyValue.Value); } return value; } private static Dictionary<long, int> Split(long value) { Dictionary<long, int> dic = new Dictionary<long, int> (); for (long i = 2; i * i <= value; i++) { while (value % i == 0) { if (!dic.ContainsKey (i)) { dic.Add (i, 0); } dic [i]++; value /= i; } } if (value != 1) { dic.Add (value, 1); } return dic; } public static void Main (string[] args) { var n = Convert.ToInt64(Console.ReadLine ()); var keys = Console.ReadLine ().Split(' ').Select(a=>Convert.ToInt64(a)).ToList(); var aCount = n / keys [0]; var bCount = n / keys [1]; var cCount = n / keys [2]; var aFactor = Split (keys [0]); var bFactor = Split (keys [1]); var cFactor = Split (keys [2]); var ab = Multiply (aFactor, bFactor); var bc = Multiply (bFactor, cFactor); var ca = Multiply (cFactor, aFactor); var abCount = n / ab; var bcCount = n / bc; var caCount = n / ca; var caFactor = Split (ca); var abc = Multiply (bFactor, caFactor); var abcCount = n / abc; var sum = aCount + bCount + cCount - abCount - bcCount - caCount + abcCount; Console.WriteLine(sum.ToString()); } } }