結果

問題 No.316 もっと刺激的なFizzBuzzをください
ユーザー 37zigen37zigen
提出日時 2016-05-18 18:24:58
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 702 bytes
コンパイル時間 2,065 ms
コンパイル使用メモリ 74,588 KB
実行使用メモリ 41,804 KB
最終ジャッジ日時 2024-04-15 22:55:33
合計ジャッジ時間 8,278 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
41,456 KB
testcase_01 AC 132 ms
41,232 KB
testcase_02 WA -
testcase_03 AC 132 ms
41,144 KB
testcase_04 AC 118 ms
39,968 KB
testcase_05 AC 129 ms
41,260 KB
testcase_06 AC 134 ms
41,192 KB
testcase_07 AC 132 ms
40,984 KB
testcase_08 AC 130 ms
41,364 KB
testcase_09 AC 131 ms
41,184 KB
testcase_10 AC 134 ms
41,448 KB
testcase_11 AC 135 ms
41,136 KB
testcase_12 AC 136 ms
41,292 KB
testcase_13 AC 135 ms
41,320 KB
testcase_14 AC 119 ms
40,016 KB
testcase_15 AC 133 ms
41,552 KB
testcase_16 AC 133 ms
41,472 KB
testcase_17 AC 133 ms
41,236 KB
testcase_18 AC 133 ms
41,804 KB
testcase_19 AC 133 ms
41,588 KB
testcase_20 AC 136 ms
41,168 KB
testcase_21 AC 132 ms
41,492 KB
testcase_22 AC 132 ms
40,972 KB
testcase_23 AC 131 ms
41,648 KB
testcase_24 AC 130 ms
41,208 KB
testcase_25 AC 135 ms
41,244 KB
testcase_26 AC 137 ms
41,340 KB
testcase_27 AC 133 ms
41,348 KB
testcase_28 AC 134 ms
41,000 KB
testcase_29 AC 131 ms
40,968 KB
testcase_30 AC 135 ms
41,304 KB
testcase_31 AC 131 ms
41,208 KB
testcase_32 AC 134 ms
41,572 KB
testcase_33 AC 121 ms
39,984 KB
testcase_34 AC 134 ms
41,316 KB
testcase_35 AC 133 ms
41,108 KB
testcase_36 AC 132 ms
41,304 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);
		int n=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		/**
		 * 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