結果

問題 No.688 E869120 and Constructing Array 2
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2018-06-09 01:26:41
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 877 bytes
コンパイル時間 1,990 ms
コンパイル使用メモリ 144,416 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-21 20:50:49
合計ジャッジ時間 3,244 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)


ll ncr(ll n, ll r) {
	if (r == 0) return 1ll;

	ll sum = 1;
	for (int i = n - r + 1; i <= n; ++i) {
		sum *= i;
	}
	for (int i = 1; i <= r; ++i) {
		sum /= i;
	}
	return sum;
}

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	for (int i = 2; i <= 30; ++i) {
		for (int j = 0; j <= i - 2; ++j) {
			int d0 = j, d1 = i - j;
			// printf("%d %d\n", d0, d1);
			ll ans = 0;
			for (int k = 0; k <= d0; ++k) {
				ans += ncr(d0, k);
			}
			// printf("ans0 %lld %lld\n", ans, ncr(d1, 2));
			ans *= ncr(d1, 2);
			// printf("ans %lld\n", ans);
			if (ans == n) {
				cout << d0 + d1 << endl;
				rep(d, d0) cout << "0 ";
				rep(d, d1) cout << "1 ";
				cout << endl;
				goto END;
			}
		}
		
	}
END:
	return 0;
}
0