結果

問題 No.593 4進FizzBuzz
ユーザー zaichuzaichu
提出日時 2017-11-18 11:02:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 678 bytes
コンパイル時間 1,357 ms
コンパイル使用メモリ 167,312 KB
実行使用メモリ 8,872 KB
最終ジャッジ日時 2024-05-04 04:32:23
合計ジャッジ時間 5,787 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 1 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 82 ms
7,504 KB
testcase_17 AC 84 ms
8,628 KB
testcase_18 AC 82 ms
7,376 KB
testcase_19 AC 80 ms
7,596 KB
testcase_20 AC 84 ms
7,372 KB
testcase_21 AC 83 ms
8,244 KB
testcase_22 AC 84 ms
8,660 KB
testcase_23 AC 85 ms
7,380 KB
testcase_24 AC 81 ms
7,500 KB
testcase_25 AC 82 ms
8,784 KB
testcase_26 AC 81 ms
8,192 KB
testcase_27 AC 83 ms
8,404 KB
testcase_28 AC 82 ms
7,280 KB
testcase_29 AC 82 ms
7,380 KB
testcase_30 AC 83 ms
7,372 KB
testcase_31 AC 86 ms
7,416 KB
testcase_32 AC 85 ms
8,384 KB
testcase_33 AC 83 ms
8,872 KB
testcase_34 AC 84 ms
7,376 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