結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー | nanophoto12 |
提出日時 | 2015-12-13 08:42:53 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 33 ms / 1,000 ms |
コード長 | 2,085 bytes |
コンパイル時間 | 2,127 ms |
コンパイル使用メモリ | 107,776 KB |
実行使用メモリ | 19,584 KB |
最終ジャッジ日時 | 2024-11-21 11:56:32 |
合計ジャッジ時間 | 3,136 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
19,328 KB |
testcase_01 | AC | 33 ms
19,456 KB |
testcase_02 | AC | 30 ms
19,200 KB |
testcase_03 | AC | 32 ms
19,328 KB |
testcase_04 | AC | 31 ms
19,328 KB |
testcase_05 | AC | 31 ms
19,328 KB |
testcase_06 | AC | 31 ms
19,328 KB |
testcase_07 | AC | 33 ms
19,328 KB |
testcase_08 | AC | 33 ms
19,456 KB |
testcase_09 | AC | 33 ms
19,200 KB |
testcase_10 | AC | 32 ms
19,200 KB |
testcase_11 | AC | 33 ms
19,328 KB |
testcase_12 | AC | 32 ms
19,328 KB |
testcase_13 | AC | 33 ms
19,456 KB |
testcase_14 | AC | 32 ms
19,456 KB |
testcase_15 | AC | 31 ms
19,584 KB |
testcase_16 | AC | 32 ms
19,456 KB |
testcase_17 | AC | 32 ms
19,200 KB |
testcase_18 | AC | 33 ms
19,328 KB |
testcase_19 | AC | 33 ms
19,456 KB |
testcase_20 | AC | 33 ms
19,456 KB |
testcase_21 | AC | 33 ms
19,456 KB |
testcase_22 | AC | 33 ms
19,328 KB |
testcase_23 | AC | 31 ms
19,328 KB |
testcase_24 | AC | 32 ms
19,456 KB |
testcase_25 | AC | 32 ms
19,328 KB |
testcase_26 | AC | 32 ms
19,456 KB |
testcase_27 | AC | 31 ms
19,328 KB |
testcase_28 | AC | 32 ms
19,200 KB |
testcase_29 | AC | 32 ms
19,328 KB |
testcase_30 | AC | 33 ms
19,328 KB |
testcase_31 | AC | 33 ms
19,328 KB |
testcase_32 | AC | 33 ms
19,456 KB |
testcase_33 | AC | 32 ms
19,200 KB |
testcase_34 | AC | 33 ms
19,200 KB |
testcase_35 | AC | 33 ms
19,456 KB |
testcase_36 | AC | 32 ms
19,584 KB |
コンパイルメッセージ
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 No316 { 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; var firstCopy = new Dictionary<long, int> (first); var secondCopy = new Dictionary<long, int> (second); foreach (var keyValue in firstCopy) { long mul = keyValue.Value; if(secondCopy.ContainsKey(keyValue.Key)){ mul = Math.Max(mul, secondCopy[keyValue.Key]); secondCopy.Remove (keyValue.Key); } value *= Pow (keyValue.Key, mul); } foreach (var keyValue in secondCopy) { value *= Pow (keyValue.Key, keyValue.Value); } return value; } private static Dictionary<long, int> Split(long value) { var cache = value; Dictionary<long, int> dic = new Dictionary<long, int> (); for (long i = 2; i * i <= cache; 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()); } } }