結果
問題 | No.593 4進FizzBuzz |
ユーザー | akusyounin2412 |
提出日時 | 2017-11-10 23:25:25 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 53 ms / 2,000 ms |
コード長 | 1,363 bytes |
コンパイル時間 | 994 ms |
コンパイル使用メモリ | 105,704 KB |
実行使用メモリ | 11,928 KB |
最終ジャッジ日時 | 2024-11-24 15:35:42 |
合計ジャッジ時間 | 3,804 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 31 |
ソースコード
# include <iostream> # include <algorithm> # include <vector> # include <string> # include <set> # include <map> # include <cmath> # include <iomanip> # include <functional> # include <tuple> # include <utility> # include <stack> # include <queue> # include <list> # include <bitset> # include <complex> # include <chrono> # include <random> # include <limits.h> # include <unordered_map> # include <unordered_set> # include <deque> # include <cstdio> # include <cstring> using namespace std; using LL = long long; using ULL = unsigned long long; constexpr long long MOD = 1000000000 + 7; constexpr long long INF = 1e17 - 10; const double PI = acos(-1); typedef pair<LL, LL> Pll; LL n, m, a[1000000] = {}, sum, ans = 0, d[1000000] = {}; bitset<10000>bi[10] = {}; struct edge { LL to, cost; }; vector<edge>vec[100000]; string st[2],str; int main() { cin >> str; bool fb[2] = {}, FF = 1; for (int i = 0; i < str.size(); i++) { sum += str[i] - '0'; } if (sum % 3 == 0)fb[0] = 1; LL i = 0; sum = 0; while (1) { if (i < str.size()) { int num = (str[i] - '0'); sum = (sum + (FF == 1 ? num % 10 : num * 4)) % 5; FF = !FF; i++; } else break; } if (sum % 5 == 0)fb[1] = 1; if (fb[0] == 0 && fb[1] == 0) cout << str << endl; else cout << (fb[0] == 1 ? (fb[1] == 1 ? "FizzBuzz" : "Fizz") : (fb[1] == 1 ? "Buzz" : "")) << endl; return 0; }