結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー zmirezzmirez
提出日時 2018-08-25 17:08:51
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 59 ms / 1,000 ms
コード長 1,363 bytes
コンパイル時間 2,768 ms
コンパイル使用メモリ 105,440 KB
実行使用メモリ 22,808 KB
最終ジャッジ日時 2023-09-08 14:15:20
合計ジャッジ時間 5,799 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
22,732 KB
testcase_01 AC 57 ms
20,808 KB
testcase_02 AC 59 ms
22,676 KB
testcase_03 AC 56 ms
20,764 KB
testcase_04 AC 57 ms
20,772 KB
testcase_05 AC 57 ms
20,716 KB
testcase_06 AC 58 ms
22,668 KB
testcase_07 AC 58 ms
20,740 KB
testcase_08 AC 58 ms
20,764 KB
testcase_09 AC 58 ms
18,716 KB
testcase_10 AC 56 ms
18,572 KB
testcase_11 AC 56 ms
20,816 KB
testcase_12 AC 56 ms
20,648 KB
testcase_13 AC 57 ms
20,820 KB
testcase_14 AC 58 ms
20,736 KB
testcase_15 AC 57 ms
20,732 KB
testcase_16 AC 57 ms
22,632 KB
testcase_17 AC 58 ms
20,816 KB
testcase_18 AC 56 ms
20,832 KB
testcase_19 AC 56 ms
22,696 KB
testcase_20 AC 56 ms
18,552 KB
testcase_21 AC 56 ms
20,768 KB
testcase_22 AC 55 ms
20,688 KB
testcase_23 AC 57 ms
20,696 KB
testcase_24 AC 56 ms
20,764 KB
testcase_25 AC 56 ms
20,652 KB
testcase_26 AC 56 ms
20,736 KB
testcase_27 AC 56 ms
20,616 KB
testcase_28 AC 57 ms
20,656 KB
testcase_29 AC 57 ms
22,772 KB
testcase_30 AC 57 ms
18,724 KB
testcase_31 AC 57 ms
22,712 KB
testcase_32 AC 56 ms
22,808 KB
testcase_33 AC 56 ms
22,780 KB
testcase_34 AC 56 ms
20,768 KB
testcase_35 AC 56 ms
20,724 KB
testcase_36 AC 56 ms
20,708 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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<m
        return m*n/gcd(n,m);


    }
    //最大公約数
    static long gcd(long n,long m){
        //n<m
        long r=0;
        while(true){
            r=m%n;
            if(r==0){
                //Console.WriteLine(n);
                return n;
            }
            m=n;
            n=r;
        }
    }
}
0