結果
問題 | No.688 E869120 and Constructing Array 2 |
ユーザー |
![]() |
提出日時 | 2018-07-23 09:00:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 1,000 ms |
コード長 | 1,119 bytes |
コンパイル時間 | 1,041 ms |
コンパイル使用メモリ | 84,668 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 05:35:20 |
合計ジャッジ時間 | 1,953 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <string> #include <complex> #include <stack> #include <queue> #include <list> #include <unordered_map> #include <utility> #include <map> #include <set> using namespace std; long long int pow(long long int n, long long int c0){ if(c0 == 0){ return 1; }else if(c0%2==0){ return pow(n*n, c0/2); }else{ return n * pow(n, c0-1); } } long long int calc(long long int n, long long int c0, long long int c1){ return c1 * (c1-1) / 2 * pow(n, c0); } int main(){ long long int k; cin >> k; long long int ans; int flag = 0; int l; int i = 0; int j = 0; for(i = 1; i <= 30; i++){ for(j = 0; j <= i; j++){ ans = calc(2, j, i-j); if(ans == k){ flag = 1; break; } } if(flag){ break; } } cout << i << endl; for(l = 0; l < j; l++){ printf("%d ", 0); } for(l = 0; l < i-j; l++){ printf("%d ", 1); } printf("\n"); }