結果
問題 |
No.593 4進FizzBuzz
|
ユーザー |
|
提出日時 | 2022-10-01 04:26:58 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 558 bytes |
コンパイル時間 | 1,894 ms |
コンパイル使用メモリ | 193,496 KB |
最終ジャッジ日時 | 2025-02-07 19:59:33 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); string s; cin >> s; string ans = ""; int sumA = 0; for(char c : s) sumA += c - '0'; if(sumA % 3 == 0) ans += "Fizz"; int n = int(s.size()); int sumB = 0; for(int i = n - 1; i >= 0; i--) { sumB += (s[i] - '0') * ((n - i) % 2 == 0 ? -1 : +1); } if(sumB % 5 == 0) ans += "Buzz"; if(ans.empty()) ans = s; cout << ans << "\n"; }