結果

問題 No.294 SuperFizzBuzz
ユーザー srjywrdnprktsrjywrdnprkt
提出日時 2023-01-16 06:16:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 70 ms / 5,000 ms
コード長 1,320 bytes
コンパイル時間 1,000 ms
コンパイル使用メモリ 110,692 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-28 19:31:27
合計ジャッジ時間 2,194 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 69 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 45 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 57 ms
4,380 KB
testcase_12 AC 64 ms
4,376 KB
testcase_13 AC 65 ms
4,380 KB
testcase_14 AC 70 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:49:19: 警告: ‘K’ may be used uninitialized [-Wmaybe-uninitialized]
   49 |     int mx = 1<<(K-1);
      |                 ~~^~~
main.cpp:34:18: 備考: ‘K’ はここで定義されています
   34 |     long long N, K, S, use;
      |                  ^

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>

using namespace std;

vector<vector<long long>> comb;

void combinations(long long n, long long modc=1e18){
    comb.resize(n+1);
    for (long long i=0; i<=n; i++){
        comb[i].resize(n+1);
        comb[i][0] = 1;
    }   

    for (long long i=1; i <= n; i++){
        for (long long j=1; j <= i; j++){
            comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % modc;
        }   
    }
}

int main(){

    long long N, K, S, use;
    cin >> N;
    combinations(30);

    for (int i=3; i<100; i++){
        S = 0;
        for (int j=1; j<=i/3; j++) S += comb[i-1][3*j-1];
        use = min(N, S);
        N -= use;
        if (N == 0){
            K = i;
            break;
        }
    }

    int mx = 1<<(K-1);
    for (int i=0; i<mx; i++){
        if ((__builtin_popcount(i)+1)%3 == 0){
            if (use>1){
                use--;
                continue;
            }
            for (int j=K-2; j>=0; j--){
                if (i & 1<<j) cout << "5";
                else cout << "3";
            }
            cout << "5" << endl;
            return 0;
        }
    }

    return 0;
}
0