結果
問題 |
No.316 もっと刺激的なFizzBuzzをください
|
ユーザー |
|
提出日時 | 2018-08-27 18:34:00 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 134 ms / 1,000 ms |
コード長 | 545 bytes |
コンパイル時間 | 2,089 ms |
コンパイル使用メモリ | 75,052 KB |
実行使用メモリ | 41,392 KB |
最終ジャッジ日時 | 2024-07-04 18:51:01 |
合計ジャッジ時間 | 8,311 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
import java.util.Scanner; class Main{ public static long gcd(long x,long y) { long r; if(y>x) { r=x; x=y; y=r; } while(y>0) { r=x%y; x=y; y=r; } return x; } public static long lcm(long x,long y) { return x*y/gcd(x,y); } public static void main(String[] args) { Scanner sc=new Scanner(System.in); long n=sc.nextLong(),a=sc.nextLong(),b=sc.nextLong(),c=sc.nextLong(); sc.close(); System.out.print(n/a+n/b+n/c-n/lcm(a,b)-n/lcm(b,c)-n/lcm(a,c)+n/lcm(lcm(a,b),c)); } }