結果

問題 No.688 E869120 and Constructing Array 2
ユーザー TAISA_TAISA_
提出日時 2018-05-18 22:31:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,015 bytes
コンパイル時間 1,480 ms
コンパイル使用メモリ 164,204 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-21 19:52:17
合計ジャッジ時間 2,764 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
ll ncr(ll n,ll r){
    ll f=1;
    for(int i=1;i<=n;i++){
        f*=i;
    }
    ll ff=1;
    for(int i=1;i<=r;i++){
        ff*=i;
    }
    ll fff=1;
    for(int i=1;i<=n-r;i++){
        fff*=i;
    }
    return f/(ff*fff);
}
int main(){
    ll n;cin>>n;
    ll t=1;
    int a=0,b=0;
    for(int i=0;i<=30;i++){
        bool f=false;
        for(int j=2;j<=30-i;j++){
            if(t*ncr(j,2)==n){
                f=true;
                a=i;b=j;
                break;
            }
        }
        t*=2;
        if(f)break;
    }
    cout<<a+b<<endl;
    for(int i=0;i<a;i++){
        cout<<0<<" ";
    }
    for(int j=0;j<b;j++){
        cout<<1;
        if(j!=b)cout<<" ";
    }
    cout<<endl;
}
0