結果

問題 No.593 4進FizzBuzz
ユーザー kappybarkappybar
提出日時 2020-05-01 14:23:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 788 bytes
コンパイル時間 1,611 ms
コンパイル使用メモリ 165,780 KB
実行使用メモリ 8,636 KB
最終ジャッジ日時 2023-08-25 18:00:25
合計ジャッジ時間 5,608 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,384 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 55 ms
7,084 KB
testcase_17 AC 54 ms
7,340 KB
testcase_18 AC 54 ms
8,112 KB
testcase_19 AC 55 ms
7,104 KB
testcase_20 AC 54 ms
8,528 KB
testcase_21 AC 55 ms
7,324 KB
testcase_22 AC 56 ms
7,044 KB
testcase_23 AC 55 ms
7,928 KB
testcase_24 AC 55 ms
8,112 KB
testcase_25 AC 54 ms
7,272 KB
testcase_26 AC 56 ms
8,204 KB
testcase_27 AC 55 ms
7,524 KB
testcase_28 AC 55 ms
7,456 KB
testcase_29 AC 55 ms
8,044 KB
testcase_30 AC 55 ms
8,636 KB
testcase_31 AC 54 ms
7,276 KB
testcase_32 AC 54 ms
7,332 KB
testcase_33 AC 56 ms
8,572 KB
testcase_34 AC 54 ms
7,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll =  long long ;
using P = pair<int,int> ;
using pll = pair<ll,ll>;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr int MOD = 1000000007;

int four(string s){
    int n = s.size();
    int base = 1;
    int res = 0;
    reverse(s.begin(),s.end());
    rep(i,n){
        int sd = ((s[i] - '0') * base)%15;
        res = (res + sd)%15;
        base = (base * 4)%15;
    }
    return res;
}

int main(){
    string s;
    cin >> s;
    int n = four(s);
    if(n%3 == 0 && n%5 ==0){
        cout << "FizzBuzz" << endl;
    }else if(n%3 ==0){
        cout << "Fizz" << endl;
    }else if(n%5 ==0){
        cout << "Buzz" << endl;
    }else{
        cout << s << endl;
    }
    return 0;
}
0