結果

問題 No.593 4進FizzBuzz
ユーザー treeonetreeone
提出日時 2017-07-04 11:09:53
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 592 bytes
コンパイル時間 1,628 ms
コンパイル使用メモリ 159,332 KB
実行使用メモリ 7,184 KB
最終ジャッジ日時 2024-04-22 14:34:39
合計ジャッジ時間 6,774 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

string solve(string s){
    int sum[2] = {};
    string res = "";
    for(int i = 0; i < s.size(); i++){
        sum[i % 2] += s[i] - '0';
    }
    if((sum[0] + sum[1]) % 3 == 0){
        res += "Fizz";
    }
    if((sum[0] - sum[1]) % 5 == 0){
        res += "Buzz";
    }
    if(res == ""){
        res = s;
    }
    return res;
}

int main(){
    string s;
    cin >> s;
    assert(1 <= s.size() && s.size() <= 100000);
    for(int i = 0; i < s.size(); i++){
        assert('0' <= s[i] && s[i] <= '3');
    }
    cout << solve(s) << endl;
}
0