結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー 37zigen37zigen
提出日時 2016-05-18 18:28:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 1,000 ms
コード長 710 bytes
コンパイル時間 2,238 ms
コンパイル使用メモリ 74,812 KB
実行使用メモリ 42,064 KB
最終ジャッジ日時 2024-05-01 09:05:46
合計ジャッジ時間 7,725 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,148 KB
testcase_01 AC 115 ms
41,112 KB
testcase_02 AC 126 ms
41,200 KB
testcase_03 AC 128 ms
41,164 KB
testcase_04 AC 130 ms
41,940 KB
testcase_05 AC 124 ms
41,676 KB
testcase_06 AC 112 ms
41,400 KB
testcase_07 AC 114 ms
41,688 KB
testcase_08 AC 122 ms
41,128 KB
testcase_09 AC 126 ms
41,452 KB
testcase_10 AC 118 ms
40,316 KB
testcase_11 AC 128 ms
41,552 KB
testcase_12 AC 126 ms
41,240 KB
testcase_13 AC 127 ms
42,064 KB
testcase_14 AC 127 ms
41,072 KB
testcase_15 AC 131 ms
41,676 KB
testcase_16 AC 129 ms
41,684 KB
testcase_17 AC 125 ms
41,428 KB
testcase_18 AC 133 ms
41,380 KB
testcase_19 AC 120 ms
40,020 KB
testcase_20 AC 125 ms
41,460 KB
testcase_21 AC 134 ms
41,584 KB
testcase_22 AC 131 ms
41,004 KB
testcase_23 AC 125 ms
41,824 KB
testcase_24 AC 125 ms
41,408 KB
testcase_25 AC 122 ms
41,324 KB
testcase_26 AC 123 ms
41,120 KB
testcase_27 AC 128 ms
41,460 KB
testcase_28 AC 123 ms
41,200 KB
testcase_29 AC 126 ms
41,372 KB
testcase_30 AC 124 ms
41,500 KB
testcase_31 AC 121 ms
41,812 KB
testcase_32 AC 122 ms
41,464 KB
testcase_33 AC 120 ms
40,368 KB
testcase_34 AC 118 ms
41,276 KB
testcase_35 AC 122 ms
41,540 KB
testcase_36 AC 108 ms
41,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		long a=sc.nextLong();
		long b=sc.nextLong();
		long c=sc.nextLong();
		/**
		 * 1<=x<=Nの範囲でa,b,cのいずれかの倍数となるものの個数を数える。
		 * 
		 */
		long ans=n/a+n/b+n/c-n/lcm(a,b)-n/lcm(b,c)-n/lcm(c,a)+n/lcm(lcm(a,b),c);
		System.out.println(ans);
	}
	long lcm(long t1,long t2){
		long a=gcd(t1,t2);
		long tt1=t1/a;
		long tt2=t2/a;
		return tt1*tt2*a;
	}
	long gcd(long t1,long t2){
		if(t1<t2){
			long d=t2;
			t2=t1;
			t1=d;
		}
		if(t2==0)return t1;
		return gcd(t2,t1%t2);
	}
}
0