結果

問題 No.294 SuperFizzBuzz
ユーザー rsk0315rsk0315
提出日時 2019-03-25 01:17:29
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 187 ms / 5,000 ms
コード長 487 bytes
コンパイル時間 577 ms
コンパイル使用メモリ 58,752 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 09:29:49
合計ジャッジ時間 2,519 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 186 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 13 ms
5,376 KB
testcase_09 AC 108 ms
5,376 KB
testcase_10 AC 108 ms
5,376 KB
testcase_11 AC 172 ms
5,376 KB
testcase_12 AC 181 ms
5,376 KB
testcase_13 AC 184 ms
5,376 KB
testcase_14 AC 187 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdint>
#include <string>

std::string nyan(int i, int j) {
  std::string res(i, '3');
  for (int k = 0; k < i; ++k)
    if (j >> k & 1)
      res[i-k-1] = '5';

  return res;
}

int main() {
  int N;
  scanf("%d", &N);

  for (int i = 3; true; ++i) {
    for (int j = 0; j < (1 << i); ++j) {
      if (!(j & 1)) continue;
      if (__builtin_popcount(j) % 3 != 0) continue;
      if (--N == 0)
        return !printf("%s\n", nyan(i, j).c_str());
    }
  }
}
0