結果

問題 No.593 4進FizzBuzz
ユーザー PachicobuePachicobue
提出日時 2017-11-10 22:28:10
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 1,159 bytes
コンパイル時間 1,443 ms
コンパイル使用メモリ 166,176 KB
実行使用メモリ 7,164 KB
最終ジャッジ日時 2023-08-16 03:01:39
合計ジャッジ時間 4,082 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 15 ms
6,844 KB
testcase_17 AC 15 ms
6,968 KB
testcase_18 AC 15 ms
7,164 KB
testcase_19 AC 17 ms
6,904 KB
testcase_20 AC 15 ms
6,940 KB
testcase_21 AC 18 ms
7,000 KB
testcase_22 AC 18 ms
6,964 KB
testcase_23 AC 16 ms
6,852 KB
testcase_24 AC 14 ms
7,020 KB
testcase_25 AC 15 ms
7,048 KB
testcase_26 AC 17 ms
6,848 KB
testcase_27 AC 16 ms
7,004 KB
testcase_28 AC 16 ms
6,904 KB
testcase_29 AC 16 ms
6,844 KB
testcase_30 AC 16 ms
7,120 KB
testcase_31 AC 16 ms
6,840 KB
testcase_32 AC 16 ms
6,916 KB
testcase_33 AC 16 ms
6,904 KB
testcase_34 AC 15 ms
6,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = (ll)1e9 + 7LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 64;


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    auto S = s;
    int mod3 = 0;
    int mod5 = 0;
    reverse(s.begin(), s.end());
    for (const char c : s) {
        mod3 = (mod3 + (c - '0') % 3) % 3;
        mod5 = (4 * mod5 + (c - '0') % 5) % 5;
    }
    if (mod3 == 0 and mod5 == 0) {
        cout << "FizzBuzz" << endl;
    } else if (mod3 == 0) {
        cout << "Fizz" << endl;
    } else if (mod5 == 0) {
        cout << "Buzz" << endl;
    } else {
        cout << S << endl;
    }
    return 0;
}
0