結果
| 問題 |
No.688 E869120 and Constructing Array 2
|
| コンテスト | |
| ユーザー |
amtgjw
|
| 提出日時 | 2018-05-22 16:38:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 744 bytes |
| コンパイル時間 | 582 ms |
| コンパイル使用メモリ | 75,212 KB |
| 実行使用メモリ | 13,756 KB |
| 最終ジャッジ日時 | 2024-07-07 14:03:33 |
| 合計ジャッジ時間 | 4,375 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | WA * 9 TLE * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:45:21: warning: ‘b’ may be used uninitialized [-Wmaybe-uninitialized]
45 | cout << (a+b) << endl;
| ^
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <complex>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPS(i,s,t) for(int i=(s);i<(t);++i)
#define INF 2000000007
#define MOD 1000000007
#define MAX 200005
typedef unsigned int uint;
typedef unsigned long long int ull;
typedef long long int ll;
int dp[MAX];
int main(){
int K;cin>>K;
int a=1,N=K;
while(K%2==0){
K/=2;
a++;
}
int b;
while(K<N){
double t = sqrt(1+8*K);
if(ceil(t) == floor(t)){
b = (t+1)/2;
break;
}
K*=2;
--a;
}
cout << (a+b) << endl;
REP(i,a) cout << 0 << " ";
REP(i,b) cout << 1 << " ";
cout << endl;
return 0;
}
amtgjw