結果

問題 No.688 E869120 and Constructing Array 2
ユーザー TAISA_TAISA_
提出日時 2018-05-18 22:51:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,127 bytes
コンパイル時間 1,271 ms
コンパイル使用メモリ 144,820 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-21 20:00:46
合計ジャッジ時間 2,435 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 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;
    if(n==0){
        cout<<1<<endl;
        cout<<1<<endl;
        return 0;
    }
    for(ll i=0;i<=30;i++){
        bool f=false;
        for(ll j=2;j<=30;j++){
            if(i+j>30)continue;
            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