結果
| 問題 |
No.688 E869120 and Constructing Array 2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-08-03 00:22:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,279 bytes |
| コンパイル時間 | 698 ms |
| コンパイル使用メモリ | 70,128 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-19 17:15:34 |
| 合計ジャッジ時間 | 1,309 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define UP(i,a,b) for(int i=(a); i<=(b); ++i)
#define DOWN(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) UP(i,0,(n)-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //NOTE: <a> must be sorted in advance
lng power(lng b, int n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n in O(log(n)) time
const int MOD = 1000000007; //10^9+7
const double PI = 3.1415926535897932384626;
/*********** variables ************/
int K;
/**********************************/
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> K;
if(K == 0) {
cout << 1 << endl;
cout << 0 << endl;
return 0;
}
UP(k, 2, 30) {
lng sol = k * (k - 1) / 2;
int m = 0;
while(m + k <= 30) {
if(sol == K) {
cout << k + m << endl;
cout << 1;
REP(i, k-1) cout << " 1";
REP(i, m) cout << " 0";
cout << endl;
return 0;
}
++m;
sol *= 2;
}
}
}