結果
| 問題 |
No.593 4進FizzBuzz
|
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2022-10-06 18:36:34 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 229 ms / 2,000 ms |
| コード長 | 1,485 bytes |
| コンパイル時間 | 2,733 ms |
| コンパイル使用メモリ | 79,540 KB |
| 実行使用メモリ | 51,816 KB |
| 最終ジャッジ日時 | 2025-01-03 12:32:26 |
| 合計ジャッジ時間 | 11,012 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 31 |
ソースコード
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner();
char[] values = sc.next().toCharArray();
int mod3 = 0;
int mod5 = 0;
for (int i = 0; i < values.length; i++) {
int x = values[i] - '0';
mod3 *= 4;
mod3 += x;
mod3 %= 3;
mod5 *= 4;
mod5 += x;
mod5 %= 5;
}
if (mod3 == 0) {
System.out.print("Fizz");
}
if (mod5 == 0) {
System.out.print("Buzz");
}
if (mod3 * mod5 > 0) {
System.out.print(values);
}
System.out.println();
}
}
class Scanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
StringBuilder sb = new StringBuilder();
public Scanner() throws Exception {
}
public int nextInt() throws Exception {
return Integer.parseInt(next());
}
public long nextLong() throws Exception {
return Long.parseLong(next());
}
public double nextDouble() throws Exception {
return Double.parseDouble(next());
}
public String next() throws Exception {
while (!st.hasMoreTokens()) {
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
}
tenten