結果
問題 |
No.593 4進FizzBuzz
|
ユーザー |
|
提出日時 | 2019-10-26 18:27:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 453 bytes |
コンパイル時間 | 1,634 ms |
コンパイル使用メモリ | 166,352 KB |
実行使用メモリ | 7,316 KB |
最終ジャッジ日時 | 2024-09-14 15:05:32 |
合計ジャッジ時間 | 5,602 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { string s; cin>>s; int n = s.length(); int mod3 = 0; int mod5 = 0; for (int i=0; i<n; i++) { int x = s[i] - '0'; mod3 = ((mod3 * 4) + x) % 3; mod5 = ((mod5 * 4) + x) % 5; } if (mod3 == 0 && mod5 == 0) { cout<<"FizzBuzz"<<endl; } else if (mod3 == 0) { cout<<"Fizz"<<endl; } else if (mod5 == 0) { cout<<"Buzz"<<endl; } else { cout<<s<<endl; } }