結果
問題 |
No.316 もっと刺激的なFizzBuzzをください
|
ユーザー |
![]() |
提出日時 | 2016-12-25 15:17:49 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 26 ms / 1,000 ms |
コード長 | 1,059 bytes |
コンパイル時間 | 955 ms |
コンパイル使用メモリ | 108,916 KB |
実行使用メモリ | 26,140 KB |
最終ジャッジ日時 | 2024-12-14 19:05:27 |
合計ジャッジ時間 | 3,187 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
コンパイルメッセージ
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; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; class Magatro { static long N; static long a, b, c; static void Main() { N = int.Parse(Console.ReadLine()); string[] s = Console.ReadLine().Split(' '); a = int.Parse(s[0]); b = int.Parse(s[1]); c = int.Parse(s[2]); long cnt = N / a + N / b + N / c; cnt += N / LCM(a, b, c); cnt -= N / LCM(a, b) + N / LCM(a, c) + N / LCM(b, c); Console.WriteLine(cnt); } static long LCM(long a,long b) { long r; long x = a * b; if (a < b) { long t = a; a = b; b = t; } r = a % b; while (r > 0) { a = b; b = r; r = a % b; } return x / b; } static long LCM(long a,long b,long c) { return LCM(LCM(a, b), c); } }