結果
| 問題 | No.316 もっと刺激的なFizzBuzzをください |
| コンテスト | |
| ユーザー |
silviasetitech
|
| 提出日時 | 2020-03-15 13:54:33 |
| 言語 | Java (openjdk 26.0.2.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 56 ms / 1,000 ms |
| + 669µs | |
| コード長 | 1,538 bytes |
| 記録 | |
| コンパイル時間 | 3,781 ms |
| コンパイル使用メモリ | 85,672 KB |
| 実行使用メモリ | 45,380 KB |
| 最終ジャッジ日時 | 2026-09-29 12:41:45 |
| 合計ジャッジ時間 | 8,087 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 33 |
ソースコード
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author silviase
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
Scanner in = new Scanner(inputStream);
PrintWriter out = new PrintWriter(outputStream);
MoreFizzBuzz solver = new MoreFizzBuzz();
solver.solve(1, in, out);
out.close();
}
static class MoreFizzBuzz {
public void solve(int testNumber, Scanner in, PrintWriter out) {
// 包徐原理を用いればいい
// -a-b-c+(ab)+(bc)+(ca)-(abc)
long n = in.nextLong();
long a = in.nextLong();
long b = in.nextLong();
long c = in.nextLong();
long res =
+(n / a) + (n / b) + (n / c)
- (n / Arith.lcm(a, b))
- (n / Arith.lcm(b, c))
- (n / Arith.lcm(c, a))
+ (n / Arith.lcm(Arith.lcm(a, b), c));
out.println(res);
}
}
static class Arith {
public static long gcd(long a, long b) {
return a % b == 0 ? b : gcd(b, a % b);
}
public static long lcm(long a, long b) {
return a / gcd(a, b) * b;
}
}
}
silviasetitech