結果

問題 No.688 E869120 and Constructing Array 2
ユーザー Kutimoti_T
提出日時 2018-05-18 22:29:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 484 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 59,356 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-07 13:18:18
合計ジャッジ時間 1,251 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string> 
#include <set>
using i64 = long long;
using namespace std;

int main(){
  i64 K;
  cin >> K;
  for(i64 a = 1;a <= 30;a++){
    for(i64 b = 0;30 - b - a >= 0;b++){
      i64 A = (a - 1) * a / 2;
      i64 B = (1LL << b);
      if(A * B == K){
        cout << a + b << endl;
        for(int i = 0;i < a;i++) cout << 1 << " ";
        for(int i = 0;i < b;i++) cout << 0 << " \n"[i + 1 == b];
        return 0;
      }
    }
  }
}
0