結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー mits58mits58
提出日時 2016-07-29 22:54:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 145 ms / 1,000 ms
コード長 473 bytes
コンパイル時間 2,056 ms
コンパイル使用メモリ 74,444 KB
実行使用メモリ 54,252 KB
最終ジャッジ日時 2024-05-01 09:07:46
合計ジャッジ時間 7,726 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
53,936 KB
testcase_01 AC 130 ms
54,168 KB
testcase_02 AC 129 ms
54,024 KB
testcase_03 AC 128 ms
54,092 KB
testcase_04 AC 114 ms
52,844 KB
testcase_05 AC 131 ms
53,988 KB
testcase_06 AC 128 ms
54,184 KB
testcase_07 AC 112 ms
52,968 KB
testcase_08 AC 125 ms
54,080 KB
testcase_09 AC 121 ms
53,984 KB
testcase_10 AC 107 ms
52,712 KB
testcase_11 AC 120 ms
53,820 KB
testcase_12 AC 123 ms
54,252 KB
testcase_13 AC 145 ms
54,008 KB
testcase_14 AC 108 ms
52,580 KB
testcase_15 AC 122 ms
54,012 KB
testcase_16 AC 106 ms
52,956 KB
testcase_17 AC 110 ms
52,736 KB
testcase_18 AC 126 ms
54,204 KB
testcase_19 AC 125 ms
54,172 KB
testcase_20 AC 125 ms
54,196 KB
testcase_21 AC 128 ms
54,076 KB
testcase_22 AC 125 ms
53,808 KB
testcase_23 AC 115 ms
52,800 KB
testcase_24 AC 113 ms
54,192 KB
testcase_25 AC 122 ms
53,904 KB
testcase_26 AC 121 ms
53,996 KB
testcase_27 AC 122 ms
54,232 KB
testcase_28 AC 109 ms
52,864 KB
testcase_29 AC 113 ms
53,772 KB
testcase_30 AC 127 ms
53,800 KB
testcase_31 AC 130 ms
53,892 KB
testcase_32 AC 130 ms
53,868 KB
testcase_33 AC 130 ms
54,052 KB
testcase_34 AC 130 ms
54,100 KB
testcase_35 AC 129 ms
54,088 KB
testcase_36 AC 129 ms
54,084 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

class Main{
	static long gcd(long a,long b){
		if(a%b==0) return b;
		return gcd(b,a%b);
	}
	static long lcm(long a,long b){
		return a/gcd(a,b)*b;
	}
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			long n=sc.nextLong();
			long a=sc.nextLong(),b=sc.nextLong(),c=sc.nextLong();
			long ans=n/a+n/b+n/c-n/lcm(a,b)-n/lcm(b,c)-n/lcm(a,c)+n/lcm(a,lcm(b,c));
			System.out.println(ans);
		}
	}
}
0