結果
問題 | No.593 4進FizzBuzz |
ユーザー |
|
提出日時 | 2017-11-12 20:44:48 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 123 ms / 2,000 ms |
コード長 | 595 bytes |
コンパイル時間 | 622 ms |
コンパイル使用メモリ | 56,724 KB |
実行使用メモリ | 8,896 KB |
最終ジャッジ日時 | 2024-11-24 23:18:25 |
合計ジャッジ時間 | 4,484 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
ソースコード
#include <iostream> #include <string> using namespace std; typedef long long LL; bool getMod(string &s,int m) { int sLen=s.length(); LL v=0; int i; LL pow4=1; for (i=sLen-1;i>=0;i--){ v+=(s[i]-'0')*pow4; pow4*=4; v%=m; pow4%=m; } if (v==0){ return true; }else{ return false; } } int main(int argc, char* argv[]) { string s; cin>>s; bool bMod3=getMod(s,3); bool bMod5=getMod(s,5); if (bMod3 && !bMod5){ cout<<"Fizz"<<endl; }else if (!bMod3 && bMod5){ cout<<"Buzz"<<endl; }else if (bMod3 && bMod5){ cout<<"FizzBuzz"<<endl; }else{ cout<<s<<endl; } return 0; }