結果

問題 No.593 4進FizzBuzz
ユーザー take000
提出日時 2021-07-03 04:10:24
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 510 bytes
コンパイル時間 2,468 ms
コンパイル使用メモリ 193,780 KB
最終ジャッジ日時 2025-01-22 17:06:38
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long ll;
using namespace std;

int main() {
    string S;
    cin >> S;

    auto f = [&](int mod) -> bool {
        int cur = 0;
        for (char c : S) {
            cur = (cur * 4 + c - '0') % mod;
        }
        return cur == 0;
    };

    string ans = "";
    if (f(3)) ans += "Fizz";
    if (f(5)) ans += "Buzz";
    if (ans == "")
        cout << S;
    else
        cout << ans;
    cout << endl;

    return 0;
}
0