結果

問題 No.294 SuperFizzBuzz
ユーザー kimiyukikimiyuki
提出日時 2016-06-07 18:37:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,140 ms / 5,000 ms
コード長 706 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 65,148 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 08:27:39
合計ジャッジ時間 7,938 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1,140 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 54 ms
5,376 KB
testcase_09 AC 615 ms
5,376 KB
testcase_10 AC 617 ms
5,376 KB
testcase_11 AC 1,038 ms
5,376 KB
testcase_12 AC 1,080 ms
5,376 KB
testcase_13 AC 1,104 ms
5,376 KB
testcase_14 AC 1,131 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
int main() {
    int n; cin >> n;
    for (int l = 0; ; ++ l) {
        repeat (s,1<<l) {
            if (not (s & 1)) continue;
            int acc = 0;
            repeat (i,l) {
                acc += (s & (1<<i)) ? 5 : 3;
            }
            if (acc % 3 == 0) {
                n -= 1;
                if (n == 0) {
                    string t(l, '3');
                    repeat (j,l) if (s & (1<<j)) t[l-j-1] = '5';
                    cout << t << endl;
                    return 0;
                }
            }
        }
    }
}
0