結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
![]() |
提出日時 | 2019-08-01 14:46:55 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 26 ms / 1,000 ms |
コード長 | 1,487 bytes |
コンパイル時間 | 803 ms |
コンパイル使用メモリ | 110,692 KB |
実行使用メモリ | 26,132 KB |
最終ジャッジ日時 | 2024-07-05 07:30:00 |
合計ジャッジ時間 | 2,733 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;class Program {static void Main(string[] args) {//入力long N = long.Parse(Console.ReadLine());string s = Console.ReadLine();long a = long.Parse(s.Split(' ')[0]);long b = long.Parse(s.Split(' ')[1]);long c = long.Parse(s.Split(' ')[2]);//回答となる数値long ans = 0;long a_num = 0; //aの倍数の個数long b_num = 0; //bの倍数の個数long c_num = 0; //cの倍数の個数long a_b_num = 0;long b_c_num = 0;long c_a_num = 0;long a_b_c_num = 0;//検証a_num = N / a;b_num = N / b;c_num = N / c;a_b_num = N / LCM(a, b);b_c_num = N / LCM(b, c);c_a_num = N / LCM(c, a);a_b_c_num = N / LCM(LCM(a, b), c);ans = a_num + b_num + c_num - (a_b_num + b_c_num + c_a_num) + a_b_c_num;//出力Console.WriteLine(ans);}//ユークリッドの互除法public static long GCD(long a, long b) {if (a < b) {return GCD(b, a);}while (b != 0) {long amari = a % b;a = b;b = amari;}return a;}//最小公倍数を求めるpublic static long LCM(long a, long b) {return a * b / GCD(a, b);}}