結果
問題 |
No.688 E869120 and Constructing Array 2
|
ユーザー |
![]() |
提出日時 | 2018-05-28 11:32:15 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 654 bytes |
コンパイル時間 | 1,635 ms |
コンパイル使用メモリ | 166,152 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-07 14:09:29 |
合計ジャッジ時間 | 1,932 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main(){ | ^~~~ main.cpp: In function 'int main()': main.cpp:27:17: warning: 'zero' may be used uninitialized [-Wmaybe-uninitialized] 27 | zero--; | ~~~~^~ main.cpp:13:11: note: 'zero' was declared here 13 | int N,zero; | ^~~~ main.cpp:24:21: warning: 'N' may be used uninitialized [-Wmaybe-uninitialized] 24 | for(int i = 0;i < N;i++){ | ~~^~~ main.cpp:13:9: note: 'N' was declared here 13 | int N,zero; | ^
ソースコード
#include<bits/stdc++.h> typedef long long ll; using namespace std; int INF = 1LL << 30; int MOD = 1e9+7; main(){ int K; cin >> K; if(K == 0){ cout << 1 << endl << 0 << endl; return 0; } int N,zero; for(int i = 1,sum = 0;sum <= K;i++){ sum += i; int num = K / sum; if(K % sum == 0 && (num & -num) == num){ zero = log2(num); N = log2(num) + i + 1; break; } } cout << N << endl; for(int i = 0;i < N;i++){ if(zero){ cout << 0 << endl; zero--; }else{ cout << 1 << endl; } } }