結果

問題 No.294 SuperFizzBuzz
ユーザー @abcde@abcde
提出日時 2019-06-30 02:39:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 966 ms / 5,000 ms
コード長 812 bytes
コンパイル時間 2,798 ms
コンパイル使用メモリ 165,044 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-17 05:57:38
合計ジャッジ時間 7,603 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 963 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 1 ms
4,380 KB
testcase_08 AC 45 ms
4,380 KB
testcase_09 AC 519 ms
4,376 KB
testcase_10 AC 512 ms
4,380 KB
testcase_11 AC 894 ms
4,376 KB
testcase_12 AC 916 ms
4,380 KB
testcase_13 AC 950 ms
4,376 KB
testcase_14 AC 966 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// ※※※ 解答不能 ※※※
// 解説サイトを見て, 解答.
// https://kimiyuki.net/writeup/algo/yukicoder/294/
#include <bits/stdc++.h>
using namespace std;

int main(){
    
    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    
    // 2. SuperFizzBuzz探索.
    for(int l = 0; ; ++l){
        for(int s = 0; s < (1<<l); ++s){
            if (not (s & 1)) continue;
            int acc = 0;
            for(int i = 0; i < l; ++i) acc += (s & (1<<i)) ? 5 : 3;
            if(acc % 3 == 0){
                N--;
                if(N == 0){
                    string t(l, '3');
                    for(int j = 0; j < l; ++j) if(s & (1<<j)) t[l - j - 1] = '5';
                    printf("%s\n", t.c_str());
                    return 0;
                }
            }
        }
    }
}
0