結果

問題 No.294 SuperFizzBuzz
ユーザー btkbtk
提出日時 2015-10-23 23:33:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 920 bytes
コンパイル時間 453 ms
コンパイル使用メモリ 52,812 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-10-01 00:32:47
合計ジャッジ時間 1,819 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;
#define LL long long
LL calc(LL d){
    LL res=0;
    LL up=1;
    LL down=1;

    for(LL i = 1; i <= d; i++){
        up*=d-i+1;
        down*=i;
        if(i%3==2)
            res+=up/down;
    }
    return res;
}
int main() {
    LL N;
    cin>>N;
    LL d=2;
    LL prev=0;
    while(true){
        LL now=calc(d);
    //    cout<<now<<endl;
        if(prev+now>=N)break;
        prev+=now;
        d++;
    }
    //printf("prev=%lld,d=%lld\n",prev,d);
    for(int bit=0;bit<(1<<d);bit++){
        if(__builtin_popcount(bit)%3==2){
            prev++;
            //cout<<prev<<endl;
            if(prev==N){
                for(int i=d-1;i>=0;i--){
                    int k=((((bit>>i)&1)==1)?5:3);
                    cout<<k;
                }
                break;
            }
        }
    }
    cout<<5<<endl;

    return 0;
}
0