結果
| 問題 |
No.688 E869120 and Constructing Array 2
|
| ユーザー |
srup٩(๑`н´๑)۶
|
| 提出日時 | 2018-06-09 01:26:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 877 bytes |
| コンパイル時間 | 1,387 ms |
| コンパイル使用メモリ | 158,564 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-07 14:14:42 |
| 合計ジャッジ時間 | 2,235 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 2 |
ソースコード
#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;
}
srup٩(๑`н´๑)۶