結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー fjafjafjafjafjafja
提出日時 2017-10-01 23:19:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 119 ms / 1,000 ms
コード長 564 bytes
コンパイル時間 2,789 ms
コンパイル使用メモリ 74,036 KB
実行使用メモリ 54,516 KB
最終ジャッジ日時 2024-04-27 17:38:07
合計ジャッジ時間 7,866 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
54,164 KB
testcase_01 AC 109 ms
53,668 KB
testcase_02 AC 113 ms
54,292 KB
testcase_03 AC 113 ms
53,888 KB
testcase_04 AC 108 ms
53,028 KB
testcase_05 AC 110 ms
53,856 KB
testcase_06 AC 111 ms
53,936 KB
testcase_07 AC 115 ms
54,516 KB
testcase_08 AC 101 ms
52,804 KB
testcase_09 AC 95 ms
52,112 KB
testcase_10 AC 97 ms
52,256 KB
testcase_11 AC 109 ms
53,212 KB
testcase_12 AC 113 ms
53,784 KB
testcase_13 AC 99 ms
52,768 KB
testcase_14 AC 105 ms
53,932 KB
testcase_15 AC 109 ms
53,764 KB
testcase_16 AC 116 ms
53,772 KB
testcase_17 AC 119 ms
53,988 KB
testcase_18 AC 98 ms
53,964 KB
testcase_19 AC 108 ms
52,752 KB
testcase_20 AC 99 ms
52,016 KB
testcase_21 AC 99 ms
53,932 KB
testcase_22 AC 104 ms
52,720 KB
testcase_23 AC 113 ms
54,020 KB
testcase_24 AC 118 ms
53,896 KB
testcase_25 AC 109 ms
53,868 KB
testcase_26 AC 118 ms
53,888 KB
testcase_27 AC 118 ms
53,820 KB
testcase_28 AC 114 ms
54,024 KB
testcase_29 AC 104 ms
53,240 KB
testcase_30 AC 110 ms
53,796 KB
testcase_31 AC 115 ms
54,108 KB
testcase_32 AC 107 ms
52,524 KB
testcase_33 AC 110 ms
52,764 KB
testcase_34 AC 114 ms
54,100 KB
testcase_35 AC 115 ms
54,000 KB
testcase_36 AC 107 ms
53,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N316 {
	static long n,a,b,c;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n=sc.nextInt();a=sc.nextInt();b=sc.nextInt();c=sc.nextInt();
		long ab=koubai(a,b,a,b);
		long bc=koubai(b,c,b,c);
		long ca=koubai(c,a,c,a);
		long abc=koubai(ab,bc,ab,bc);
			System.out.println(n/a+n/b+n/c-n/ab-n/bc-n/ca+n/abc);
	}

	static long koubai(long a,long b,long aa,long bb){
		return a*b/gcd(a,b);
	}
	static long gcd(long a,long b){
		if(a%b==0){
			return b;
		}else{
			return gcd(b,a%b);
		}
	}
}
0