結果

問題 No.593 4進FizzBuzz
ユーザー 👑 CleyL
提出日時 2020-02-18 14:49:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 537 bytes
コンパイル時間 580 ms
コンパイル使用メモリ 67,456 KB
実行使用メモリ 7,316 KB
最終ジャッジ日時 2024-10-06 15:33:36
合計ジャッジ時間 3,525 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    string s;cin>>s;
    reverse(s.begin(),s.end());
    int mod = 15;
    int r = 1;
    int nya = 0;
    for(int i = 0; s.size() > i; i++){
        nya = (nya +r*(s[i]-'0'))%mod;
        r = (r*4)%mod;
    }
    if(!(nya%15)){
        cout << "FizzBuzz" << endl;
    }else if(!(nya % 3)){
        cout <<  "Fizz" << endl;
    }else if(!(nya % 5)){
        cout << "Buzz" << endl;
    }else{
        reverse(s.begin(),s.end());
        cout << s << endl;
    }
}
0