結果

問題 No.593 4進FizzBuzz
ユーザー lucky3977lucky3977
提出日時 2019-02-14 13:53:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 68,360 KB
実行使用メモリ 8,580 KB
最終ジャッジ日時 2023-10-11 12:35:33
合計ジャッジ時間 4,607 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,356 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,356 KB
testcase_06 AC 2 ms
4,356 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 2 ms
4,372 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,356 KB
testcase_16 AC 86 ms
7,100 KB
testcase_17 AC 85 ms
7,216 KB
testcase_18 AC 86 ms
8,580 KB
testcase_19 AC 86 ms
7,376 KB
testcase_20 AC 85 ms
7,760 KB
testcase_21 AC 86 ms
7,816 KB
testcase_22 AC 86 ms
7,916 KB
testcase_23 AC 86 ms
7,616 KB
testcase_24 AC 86 ms
8,032 KB
testcase_25 AC 85 ms
7,736 KB
testcase_26 AC 87 ms
8,300 KB
testcase_27 AC 86 ms
7,348 KB
testcase_28 AC 85 ms
8,200 KB
testcase_29 AC 87 ms
7,648 KB
testcase_30 AC 86 ms
7,508 KB
testcase_31 AC 87 ms
8,140 KB
testcase_32 AC 85 ms
7,552 KB
testcase_33 AC 87 ms
7,216 KB
testcase_34 AC 85 ms
7,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>

using namespace std;

bool check(string s, int m){
    int t = 0;
    for(int i = 0; i < s.size(); i++){
        t = (t * 4 + (s[i] - '0')) % m;
    }
    if(t == 0){
        return true;
    }else{
        return false;
    }
}

int main(){
    string n;
    cin >> n;
    bool f1 = check(n, 3), f2 = check(n, 5);
    if(f1 && f2){
        cout << "FizzBuzz" << endl;
    }else if(f1){
        cout << "Fizz" << endl;
    }else if(f2){
        cout << "Buzz" << endl;
    }else{
        cout << n << endl;
    }
    return 0;
}
0