結果

問題 No.593 4進FizzBuzz
ユーザー ManjushriMitraManjushriMitra
提出日時 2024-07-27 15:54:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 892 bytes
コンパイル時間 1,830 ms
コンパイル使用メモリ 169,216 KB
実行使用メモリ 9,264 KB
最終ジャッジ日時 2024-07-27 15:55:00
合計ジャッジ時間 5,496 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 59 ms
7,508 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 59 ms
7,376 KB
testcase_22 AC 61 ms
7,532 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 67 ms
8,072 KB
testcase_26 AC 63 ms
7,248 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 61 ms
7,248 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 58 ms
8,124 KB
testcase_33 AC 59 ms
8,540 KB
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

bool is_fizz(string str){
    int base = 1, res = 0;
    int n = str.size();
    for(int i = n-1; i >= 0; --i){
        res += (str[i] - '0')*base;
        res %= 3;
        base *= 4;
    }
    return res == 0;
}

bool is_buzz(string str){
    int base = 1, res = 0;
    int n = str.size();
    for(int i = n-1; i >= 0; --i){
        res += (str[i] - '0')*base;
        res %= 5;
        base *= 4;
    }
    return res == 0;
}

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

    bool fizz = is_fizz(N), buzz = is_buzz(N);

    if(fizz && buzz){
        cout << "FizzBuzz" << endl;
    }else if(fizz){
        cout << "Fizz" << endl;
    }else if(buzz){
        cout << "Buzz" << endl;
    }else{
        cout << N << endl;
    }
    return 0;
}
0