結果
| 問題 |
No.688 E869120 and Constructing Array 2
|
| コンテスト | |
| ユーザー |
amtgjw
|
| 提出日時 | 2018-05-22 16:57:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 850 bytes |
| コンパイル時間 | 682 ms |
| コンパイル使用メモリ | 73,244 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-07 14:04:33 |
| 合計ジャッジ時間 | 1,445 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#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[32];
int main(){
int K;cin>>K;
if(K==0){
cout << "2" << endl;
cout << "0 1" << endl;
return 0;
}
int a=0,b=0;
int N=K;
while(K%2==0){
K/=2;
a++;
}
REPS(i,2,31){
dp[i] = i*(i-1)/2;
}
REP(i,30){
REP(j,31)
if(dp[j]==K){
b=j;
break;
}
if(b > 0) break;
K*=2;
--a;
}
cout << (a+b) << endl;
REP(i,a) cout << 0 << " ";
REP(i,b) cout << 1 << " ";
cout << endl;
return 0;
}
amtgjw