結果
問題 | No.294 SuperFizzBuzz |
ユーザー |
![]() |
提出日時 | 2020-04-10 22:15:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 59 ms / 5,000 ms |
コード長 | 933 bytes |
コンパイル時間 | 939 ms |
コンパイル使用メモリ | 76,612 KB |
最終ジャッジ日時 | 2025-01-09 16:13:51 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
#include <iostream>#include <algorithm>#include <vector>using namespace std;#define rep(i,n) for(int i=0;i<(n);++i)int main() {int N; cin >> N;int comb[40][40];comb[0][0] = 1;rep(i, 40-1) {comb[i+1][0] = 1;rep(j, 40-1)comb[i+1][j+1] = comb[i][j] + comb[i][j+1];}int tmp = 0;rep(i, 30) {// n桁での個数列挙int n = i + 2;int tmp2 = 0;for (int k = 2; n >= k; k += 3)tmp2 += comb[n][k];tmp += tmp2;if (tmp < N)continue;tmp -= tmp2;n = 2;rep(i, N - tmp) {++n;while (__builtin_popcountll(n) % 3 != 2)++n;}vector<int> ans;for (; n > 0; n /= 2)ans.push_back(n % 2);while ((int)ans.size() < i+2)ans.push_back(0);reverse(ans.begin(), ans.end());for (const auto& e : ans)cout << (e == 0 ? 3 : 5);cout << 5 << endl;return 0;}return 0;}