結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー fjafjafjafjafjafja
提出日時 2017-10-01 23:19:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 1,000 ms
コード長 564 bytes
コンパイル時間 4,164 ms
コンパイル使用メモリ 71,724 KB
実行使用メモリ 56,004 KB
最終ジャッジ日時 2023-08-09 23:26:48
合計ジャッジ時間 9,592 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,748 KB
testcase_01 AC 121 ms
55,624 KB
testcase_02 AC 124 ms
55,552 KB
testcase_03 AC 126 ms
55,900 KB
testcase_04 AC 123 ms
55,556 KB
testcase_05 AC 126 ms
55,620 KB
testcase_06 AC 123 ms
55,760 KB
testcase_07 AC 120 ms
55,688 KB
testcase_08 AC 124 ms
55,764 KB
testcase_09 AC 124 ms
55,624 KB
testcase_10 AC 124 ms
56,004 KB
testcase_11 AC 124 ms
55,400 KB
testcase_12 AC 122 ms
55,548 KB
testcase_13 AC 124 ms
55,792 KB
testcase_14 AC 120 ms
55,392 KB
testcase_15 AC 121 ms
55,384 KB
testcase_16 AC 121 ms
53,552 KB
testcase_17 AC 120 ms
55,640 KB
testcase_18 AC 122 ms
55,880 KB
testcase_19 AC 122 ms
55,824 KB
testcase_20 AC 121 ms
55,532 KB
testcase_21 AC 122 ms
55,944 KB
testcase_22 AC 122 ms
55,764 KB
testcase_23 AC 122 ms
55,880 KB
testcase_24 AC 122 ms
55,584 KB
testcase_25 AC 123 ms
55,356 KB
testcase_26 AC 123 ms
55,472 KB
testcase_27 AC 123 ms
55,624 KB
testcase_28 AC 125 ms
55,816 KB
testcase_29 AC 128 ms
55,532 KB
testcase_30 AC 125 ms
55,728 KB
testcase_31 AC 123 ms
55,608 KB
testcase_32 AC 125 ms
55,596 KB
testcase_33 AC 124 ms
55,932 KB
testcase_34 AC 125 ms
55,604 KB
testcase_35 AC 126 ms
55,948 KB
testcase_36 AC 129 ms
55,716 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