結果

問題 No.294 SuperFizzBuzz
ユーザー face4face4
提出日時 2019-09-25 16:37:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 363 ms / 5,000 ms
コード長 997 bytes
コンパイル時間 1,198 ms
コンパイル使用メモリ 68,688 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 07:07:15
合計ジャッジ時間 3,351 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 360 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 16 ms
4,348 KB
testcase_09 AC 221 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 297 ms
4,348 KB
testcase_12 AC 325 ms
4,348 KB
testcase_13 AC 342 ms
4,348 KB
testcase_14 AC 363 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;

typedef long long ll;

ll comb(int n, int c){
    ll ret = 1;
    for(int i = 0; i < c; i++){
        ret *= (n-i);
        ret /= i+1;
    }
    return ret;
}

int main(){
    int n;
    cin >> n;

    n--;
    int len = 3;
    while(true){
        ll tmp = 0;
        for(int five = 2; five+1 <= len; five += 3){
            tmp += comb(len-1, five);
        }
        if(n < tmp) break;
        n -= tmp;
        len++;
    }

    for(int i = 0; i < 1<<(len-1); i++){
        int popcnt = 0;
        for(int j = 0; j < len-1; j++){
            if((i>>j)&1)    popcnt++;
        }
        if(popcnt%3 == 2){
            n--;
            if(n < 0){
                string ret = "5";
                for(int j = 0; j < len-1; j++){
                    ret += "35"[(i>>j)&1];
                }
                reverse(ret.begin(), ret.end());
                cout << ret << endl;
                return 0;
            }
        }
    }
}
0