結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー kou6839
提出日時 2015-12-09 15:57:25
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 453 bytes
コンパイル時間 2,047 ms
コンパイル使用メモリ 74,104 KB
実行使用メモリ 54,084 KB
最終ジャッジ日時 2024-09-15 05:51:43
合計ジャッジ時間 8,529 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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