結果

問題 No.294 SuperFizzBuzz
ユーザー outlineoutline
提出日時 2021-02-22 16:10:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,718 ms / 5,000 ms
コード長 1,737 bytes
コンパイル時間 1,449 ms
コンパイル使用メモリ 140,404 KB
実行使用メモリ 135,072 KB
最終ジャッジ日時 2023-10-21 11:25:41
合計ジャッジ時間 16,896 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 408 ms
4,348 KB
testcase_01 AC 844 ms
4,348 KB
testcase_02 AC 861 ms
134,828 KB
testcase_03 AC 538 ms
4,348 KB
testcase_04 AC 621 ms
4,348 KB
testcase_05 AC 469 ms
4,348 KB
testcase_06 AC 950 ms
4,348 KB
testcase_07 AC 1,105 ms
4,348 KB
testcase_08 AC 1,718 ms
11,972 KB
testcase_09 AC 1,500 ms
69,544 KB
testcase_10 AC 1,532 ms
69,544 KB
testcase_11 AC 926 ms
135,072 KB
testcase_12 AC 912 ms
135,072 KB
testcase_13 AC 860 ms
135,072 KB
testcase_14 AC 841 ms
135,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
using namespace std;

using ll = long long;
constexpr int INF = 1001001001;
// constexpr int mod = 1000000007;
constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;

    priority_queue<pair<int, int>> que;
    for(int mask = 1; mask < 1 << 25; ++mask){
        if((__builtin_popcount(mask) % 3 == 0) && (mask % 2 == 1)){
            int msb = 25;
            for(int k = 24; k >= 0; --k){
                if(mask >> k & 1){
                    msb = k;
                    break;
                }
            }
            for(int i = msb + 1; i <= 25; ++i){
                que.emplace(i, mask);
                if(que.size() > N)  que.pop();
            }
        }
    }

    int d = que.top().first, mask = que.top().second;
    string ans = "";
    for(int i = 0; i < d; ++i){
        ans += (mask >> i & 1) ? '5' : '3';
    }
    reverse(begin(ans), end(ans));
    cout << ans << endl;

    return 0;
}
0