結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
|
提出日時 | 2018-08-25 17:08:51 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 24 ms / 1,000 ms |
コード長 | 1,363 bytes |
コンパイル時間 | 2,408 ms |
コンパイル使用メモリ | 104,576 KB |
実行使用メモリ | 17,920 KB |
最終ジャッジ日時 | 2024-06-26 07:21:40 |
合計ジャッジ時間 | 4,274 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;class Program{static void Main(string[]args){long N=int.Parse(Console.ReadLine());string[]t=Console.ReadLine().Split(' ');long[]a=new long[t.Length];long count=0;long div=0;for(int i=0;i<t.Length;i++){a[i]=int.Parse(t[i]);}if(a[2]%a[0]==0 && a[1]%a[0]==0 ){count=N/a[0];}else if(a[2]%a[1]==0 || a[2]%a[0]==0){div=N/(lcm(a[0],a[1]));count=N/a[1]+N/a[0]-div;}else if(a[1]%a[0]==0){div=N/(lcm(a[0],a[2]));count=N/a[2]+N/a[0]-div;}else{div =N/lcm(a[0],a[1])+N/lcm(a[0],a[2])+N/lcm(a[1],a[2]);//Console.WriteLine((a[0]*a[1]*a[2]));count=N/a[0]+N/a[1]+N/a[2]-div+N/(lcm(a[0],lcm(a[1],a[2])));//count=N/a[0]+N/a[1]+N/a[2]-div+N/(a[0]*a[1]*a[2]);}Console.WriteLine(count);}//最大公倍数を求めるstatic long lcm(long n,long m){//n<mreturn m*n/gcd(n,m);}//最大公約数static long gcd(long n,long m){//n<mlong r=0;while(true){r=m%n;if(r==0){//Console.WriteLine(n);return n;}m=n;n=r;}}}