結果

問題 No.294 SuperFizzBuzz
ユーザー btkbtk
提出日時 2015-10-23 23:52:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 99 ms / 5,000 ms
コード長 1,014 bytes
コンパイル時間 396 ms
コンパイル使用メモリ 53,020 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 04:45:04
合計ジャッジ時間 2,129 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

using namespace std;
#define LL long long

LL gcd(LL a,LL b){
    return (b==0)?a:gcd(b,a%b);
}

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;
        LL k=gcd(up,down);
        up/=k;
        down/=k;
        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++;
    }
    int cnt=0;
    //printf("prev=%lld,d=%lld\n",prev,d);
    for(int bit=0;bit<(1<<d);bit++){

        if(__builtin_popcount(bit)%3==2){
            cnt++;
            prev++;
            if(prev==N){
                for(int i=d-1;i>=0;i--){
                    int k=((((bit>>i)&1)==1)?5:3);
                    cout<<k;
                }
            }
        }
    }

    cout<<5<<endl;
    return 0;
}
0