結果

問題 No.593 4進FizzBuzz
ユーザー fushime2fushime2
提出日時 2017-11-21 21:09:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 2,485 ms
コンパイル使用メモリ 145,216 KB
実行使用メモリ 8,788 KB
最終ジャッジ日時 2023-08-17 11:58:25
合計ジャッジ時間 4,558 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 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,376 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 57 ms
7,692 KB
testcase_17 AC 66 ms
8,788 KB
testcase_18 AC 57 ms
6,900 KB
testcase_19 AC 67 ms
6,976 KB
testcase_20 AC 49 ms
8,484 KB
testcase_21 AC 57 ms
8,028 KB
testcase_22 AC 67 ms
8,136 KB
testcase_23 AC 49 ms
7,596 KB
testcase_24 AC 66 ms
8,700 KB
testcase_25 AC 65 ms
6,940 KB
testcase_26 AC 67 ms
7,184 KB
testcase_27 AC 67 ms
8,496 KB
testcase_28 AC 49 ms
6,976 KB
testcase_29 AC 66 ms
7,500 KB
testcase_30 AC 49 ms
8,224 KB
testcase_31 AC 57 ms
8,472 KB
testcase_32 AC 66 ms
6,904 KB
testcase_33 AC 66 ms
7,696 KB
testcase_34 AC 57 ms
7,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(int (i)=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)

bool f(string& s, int mod) {
    int x = 1, t = 0;
    int n = s.size();
    rep(i, n) {
        int b = s[n - 1 - i] - '0';
        t = (t + b * x) % mod;
        x = (x * 4) % mod;
    }
    return t == 0;
}


int main() {
    string s;
    cin >> s;
    
    if (f(s, 15)) {
        cout << "FizzBuzz" << endl;
    }
    else if (f(s, 3)) {
        cout << "Fizz" << endl;
    }
    else if (f(s, 5)) {
        cout << "Buzz" << endl;
    }
    else {
        cout << s << endl;
    }

    return 0;
}
0