結果

問題 No.294 SuperFizzBuzz
ユーザー MisterMister
提出日時 2020-09-10 22:28:50
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3,204 ms / 5,000 ms
コード長 844 bytes
コンパイル時間 825 ms
コンパイル使用メモリ 85,068 KB
実行使用メモリ 462,128 KB
最終ジャッジ日時 2023-08-25 18:34:21
合計ジャッジ時間 21,725 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3,204 ms
461,976 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 154 ms
33,380 KB
testcase_09 AC 1,442 ms
232,584 KB
testcase_10 AC 3,117 ms
461,680 KB
testcase_11 AC 3,039 ms
461,772 KB
testcase_12 AC 2,985 ms
462,128 KB
testcase_13 AC 3,030 ms
461,868 KB
testcase_14 AC 3,003 ms
461,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using lint = long long;

void solve() {
    int n;
    std::cin >> n;
    --n;

    for (int m = 1;; ++m) {
        std::vector<std::string> ss;
        for (int b = 0; b < (1 << m); ++b) {
            if ((b & 1) == 0 || __builtin_popcount(b) % 3 != 0) continue;

            std::string s(m, '$');
            for (int j = 0; j < m; ++j) s[j] = "35"[(b >> j) & 1];
            std::reverse(s.begin(), s.end());
            ss.push_back(s);
        }

        int k = ss.size();
        if (k <= n) {
            n -= k;
            continue;
        }

        std::sort(ss.begin(), ss.end());
        std::cout << ss[n] << "\n";
        return;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0