結果
問題 | No.593 4進FizzBuzz |
ユーザー |
![]() |
提出日時 | 2019-04-01 16:14:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,441 bytes |
コンパイル時間 | 1,606 ms |
コンパイル使用メモリ | 167,240 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-25 06:43:12 |
合計ジャッジ時間 | 5,167 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 WA * 19 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" using namespace std; #define rep(i, n) for(int i=0; i<(n); ++i) #define FOR(i, m, n) for(int i=(m); i<(n); ++i) #define sz(x) ((int)(x).size()) #define all(x) (x).begin(),(x).end() #define mp make_pair #define pb push_back #define Cout(x) cout << (x) << endl #define Cout2(x, y) cout << (x) << " " << (y) << endl #define dump(x) cerr << #x << " = " << (x) << endl; typedef long long LL; typedef vector<int> VI; typedef vector<LL> VL; typedef vector<string> VS; typedef vector<bool> VB; typedef vector<vector<int>> VVI; typedef pair<int, int> PII; const int inf = 1e9; const double pi = acos(-1.0); class Radix { const char* s; int a[128]; public: Radix(const char* s = "0123456789ABCDEF") : s(s) { for (int i = 0; s[i]; ++i)a[(int)s[i]] = i; } string to(long long x, int y) { if (!x)return "0"; int i; char t[64] = { }; for (i = 62; x; --i) { t[i] = s[x % y]; x /= y; } return string(t + i + 1); } string to(const string& t, int x, int y) { return to(to(t, x), y); } long long to(const string& t, int x) { long long sm = a[(int)t[0]]; for (int i = 1; i < (int)t.size(); ++i)sm = sm * x + a[(int)t[i]]; return sm; } }; int main() { int n; cin >> n; Radix r; int x = r.to(to_string(n), 4); if (x % 15 == 0) { puts("FizzBuzz"); } else if (x % 3 == 0) { puts("Fizz"); } else if (x % 5 == 0) { puts("Buzz"); } else { Cout(n); } }