結果

問題 No.593 4進FizzBuzz
ユーザー zaichuzaichu
提出日時 2017-11-18 11:02:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 678 bytes
コンパイル時間 1,621 ms
コンパイル使用メモリ 165,332 KB
実行使用メモリ 9,068 KB
最終ジャッジ日時 2023-08-16 21:07:38
合計ジャッジ時間 6,650 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,388 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 86 ms
7,548 KB
testcase_17 AC 87 ms
7,636 KB
testcase_18 AC 86 ms
7,380 KB
testcase_19 AC 87 ms
8,492 KB
testcase_20 AC 87 ms
8,772 KB
testcase_21 AC 86 ms
9,004 KB
testcase_22 AC 87 ms
7,676 KB
testcase_23 AC 86 ms
9,068 KB
testcase_24 AC 85 ms
8,684 KB
testcase_25 AC 86 ms
7,748 KB
testcase_26 AC 86 ms
7,988 KB
testcase_27 AC 86 ms
7,352 KB
testcase_28 AC 86 ms
7,248 KB
testcase_29 AC 86 ms
8,780 KB
testcase_30 AC 85 ms
7,888 KB
testcase_31 AC 86 ms
8,524 KB
testcase_32 AC 86 ms
8,532 KB
testcase_33 AC 87 ms
7,404 KB
testcase_34 AC 86 ms
7,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

template <typename T>
T gcd(T x, T y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

template <typename T>
T lcm(T x, T y)
{
    if (x == 0 || y == 0)
        return 0;
    return x / gcd(x, y) * y;
}

bool hoge(string N, int mod)
{
    int n = N.size();
    int val = 0;
    for (int i = 0; i < n; i++)
        val = (val * 4 + (N[i] - '0')) % mod;
    return val % mod == 0;
}

int main()
{
    string N;
    cin >> N;
    string ans = "";
    if (hoge(N, 3))
        ans += "Fizz";
    if (hoge(N, 5))
        ans += "Buzz";
    if (ans == "")
        cout << N << endl;
    else
        cout << ans << endl;
}
0