結果
| 問題 |
No.389 ロジックパズルの組み合わせ
|
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2016-07-09 00:03:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 769 bytes |
| コンパイル時間 | 457 ms |
| コンパイル使用メモリ | 60,888 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-10-13 07:41:45 |
| 合計ジャッジ時間 | 4,208 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 3 TLE * 1 -- * 89 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int main(){
int m;
cin >> m;
int k;
int cnt = 0;
long long int sum = 0;
long long res = 1;
while (cin >> k) {
if (k == 0) {
cout << "1" << endl;
return 0;
}
sum += k;
cnt++;
}
m = m - sum - cnt + 1;
if (m < 0) {
cout << "NA" << endl;
return 0;
}
else {
vector<int> waru;
for (int i = 1; i <= cnt; i++) {
waru.push_back(i);
}
for (int i = 1; i <= cnt; i++) {
res *= (i + m);
for (int j = 0; j < waru.size(); j++) {
if (!(res % waru[j])){
res = res / waru[j];
waru.erase(waru.begin() + j);
j--;
}
}
cout << i + m << endl;
cout << res << endl;
if (res > 1000000007) res %= 1000000007;
}
}
cout << res << endl;
return 0;
}
kurenai3110