結果
問題 |
No.593 4進FizzBuzz
|
ユーザー |
![]() |
提出日時 | 2020-12-17 18:21:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 560 bytes |
コンパイル時間 | 2,233 ms |
コンパイル使用メモリ | 192,644 KB |
最終ジャッジ日時 | 2025-01-17 02:27:58 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string S; cin >> S; int res = 0, b = 1; reverse(S.begin(), S.end()); for (int i = 0; i < (int)S.size(); i++) { res += (S[i] - '0') * b; res %= 15; b *= 4; b %= 15; } if (res % 15 == 0) { cout << "FizzBuzz" << '\n'; } else if (res % 3 == 0) { cout << "Fizz" << '\n'; } else if (res % 5 == 0) { cout << "Buzz" << '\n'; } else { reverse(S.begin(), S.end()); cout << S << '\n'; } return 0; }