結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
|
提出日時 | 2023-07-27 11:33:56 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 56 ms / 1,000 ms |
コード長 | 1,160 bytes |
コンパイル時間 | 14,515 ms |
コンパイル使用メモリ | 167,364 KB |
実行使用メモリ | 183,876 KB |
最終ジャッジ日時 | 2024-10-04 05:47:00 |
合計ジャッジ時間 | 14,465 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (115 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
using System;using System.Collections.Generic;using System.Linq;namespace yukicoder{public class Program{public static void Main(){var n = int.Parse(Console.ReadLine());var a = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToArray();if (a[1] % a[0] == 0 && a[2] % a[0] == 0){Console.WriteLine(n / a[0]);}else if (a[1] % a[0] == 0){Console.WriteLine(n / a[0] + n / a[2] - n / Lcm(a[0] , a[2]));}else if (a[2] % a[0] == 0 || a[2] % a[1] == 0){Console.WriteLine(n / a[0] + n / a[1] - n / Lcm(a[0] , a[1]));}else{Console.WriteLine(n / a[0] + n / a[1] + n / a[2] - n / Lcm(a[0] , a[1]) - n / Lcm(a[1] , a[2]) - n / Lcm(a[0] , a[2]) + n / Lcm(a[0] ,Lcm(a[1] , a[2])));}}public static long Lcm(long a, long b){return a * b / Gcd(a, b);}// ユークリッドの互除法public static long Gcd(long a, long b){if (a < b)// 引数を入替えて自分を呼び出すreturn Gcd(b, a);while (b != 0){var remainder = a % b;a = b;b = remainder;}return a;}}}