結果
問題 | No.316 もっと刺激的なFizzBuzzをください |
ユーザー |
![]() |
提出日時 | 2016-07-29 22:54:46 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 132 ms / 1,000 ms |
コード長 | 473 bytes |
コンパイル時間 | 2,352 ms |
コンパイル使用メモリ | 77,428 KB |
実行使用メモリ | 41,520 KB |
最終ジャッジ日時 | 2024-11-21 12:22:03 |
合計ジャッジ時間 | 7,786 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 33 |
ソースコード
import java.util.Scanner;class Main{static long gcd(long a,long b){if(a%b==0) return b;return gcd(b,a%b);}static long lcm(long a,long b){return a/gcd(a,b)*b;}public static void main(String[] args){Scanner sc=new Scanner(System.in);while(sc.hasNext()){long n=sc.nextLong();long a=sc.nextLong(),b=sc.nextLong(),c=sc.nextLong();long ans=n/a+n/b+n/c-n/lcm(a,b)-n/lcm(b,c)-n/lcm(a,c)+n/lcm(a,lcm(b,c));System.out.println(ans);}}}