結果

問題 No.294 SuperFizzBuzz
ユーザー kimiyuki
提出日時 2016-06-07 18:37:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,295 ms / 5,000 ms
コード長 706 bytes
コンパイル時間 541 ms
コンパイル使用メモリ 66,460 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-11 01:03:35
合計ジャッジ時間 9,031 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

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