結果
問題 |
No.873 バイナリ、ヤバいなり!w
|
ユーザー |
![]() |
提出日時 | 2019-08-30 23:18:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,287 bytes |
コンパイル時間 | 2,008 ms |
コンパイル使用メモリ | 174,168 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-24 01:46:12 |
合計ジャッジ時間 | 3,866 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 WA * 14 |
ソースコード
#include <bits/stdc++.h> #define REP(i, start, end) for (int i=start, i##Len=(end); i < i##Len; ++i) using ll = int64_t; using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int N; cin >> N; static int dp[300010] = {}; static int from[300010] = {}; dp[N] = 1; while (dp[0] == 0) { REP(i, 0, N+1) if (dp[i] > 0) { ll base = 1; while (base*base <= i) { dp[i-base*base] = dp[i]+1; from[i-base*base] = base; ++base; } } } vector<int> result; int i = 0; while (i < N) { result.push_back(from[i]); i += from[i]*from[i]; } string answer = ""; sort(result.begin(), result.end()); for (auto x: result) { if (x % 2 == 0) continue; answer += "0"; REP(i, 0, (x-1)/2) answer += "10"; } int first_zero = 1; for (int i=result.size()-1; i >= 0; --i) { if (result[i] % 2) continue; if (first_zero) { REP(j, 0, result[i]/2) answer += "01"; } else { REP(j, 0, result[i]/2) answer += "10"; } first_zero ^= 1; } cout << answer << endl; return 0; }