結果

問題 No.688 E869120 and Constructing Array 2
ユーザー tetsutetsu
提出日時 2018-05-18 22:35:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 537 bytes
コンパイル時間 1,414 ms
コンパイル使用メモリ 164,328 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-21 19:53:15
合計ジャッジ時間 2,371 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,388 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll pow(ll a, ll b) {
  if(b==0) return 1;
  if(b%2==0) {
    ll t = pow(a, b/2);
    return t*t;
  } else {
    return a*pow(a, b-1);
  }
}
int main() {
  ll k;
  cin >> k;
  for(int n=2; n<=30; n++) {
    for(int a=2; a<=n; a++) {
      int b = n-a;
      if(pow(2, b)*a*(a-1)/2==k) {
	cout << n << endl;
	cout << "1";
	for(int i=1; i<a; i++) {
	  cout << " 1";
	}
	for(int i=0; i<b; i++) {
	  cout << " 0";
	}
	cout << endl;
	return 0;
      }
    }
  }
  return 0;
}
0