結果

問題 No.294 SuperFizzBuzz
ユーザー kimiyukikimiyuki
提出日時 2016-06-07 18:37:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,131 ms / 5,000 ms
コード長 706 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 64,696 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-01 09:00:51
合計ジャッジ時間 8,556 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1,095 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 52 ms
4,380 KB
testcase_09 AC 616 ms
4,376 KB
testcase_10 AC 614 ms
4,376 KB
testcase_11 AC 1,131 ms
4,376 KB
testcase_12 AC 1,055 ms
4,380 KB
testcase_13 AC 1,077 ms
4,376 KB
testcase_14 AC 1,098 ms
4,384 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