結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
![]() |
提出日時 | 2016-11-17 02:36:44 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 118 ms / 1,000 ms |
コード長 | 696 bytes |
コンパイル時間 | 1,824 ms |
コンパイル使用メモリ | 74,684 KB |
実行使用メモリ | 41,344 KB |
最終ジャッジ日時 | 2024-11-26 02:43:12 |
合計ジャッジ時間 | 7,037 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
import java.util.*;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(System.in);long N = sc.nextInt();long a = sc.nextInt();long b = sc.nextInt();long c = sc.nextInt();long ablcm = a*b/gcd(a,b);long bclcm = b*c/gcd(b,c);long calcm = c*a/gcd(c,a);long ALLlcm = ablcm*c/gcd(ablcm,c);long num=N/a+N/b+N/c-N/ablcm-N/bclcm-N/calcm+N/ALLlcm;System.out.println(num);}static long gcd(long x, long y){while(true){long t=x%y;x=y;y=t;if(t==0){break;}}return x;}}