結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-11-08 23:59:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,496 bytes
コンパイル時間 604 ms
コンパイル使用メモリ 62,656 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-03 23:48:45
合計ジャッジ時間 4,622 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 54 ms
5,376 KB
testcase_50 AC 5 ms
5,376 KB
testcase_51 AC 4 ms
5,376 KB
testcase_52 AC 12 ms
5,376 KB
testcase_53 AC 7 ms
5,376 KB
testcase_54 AC 14 ms
5,376 KB
testcase_55 AC 2 ms
5,376 KB
testcase_56 AC 6 ms
5,376 KB
testcase_57 AC 24 ms
5,376 KB
testcase_58 AC 45 ms
5,376 KB
testcase_59 AC 34 ms
5,376 KB
testcase_60 AC 16 ms
5,376 KB
testcase_61 AC 71 ms
5,376 KB
testcase_62 AC 17 ms
5,376 KB
testcase_63 AC 46 ms
5,376 KB
testcase_64 AC 13 ms
5,376 KB
testcase_65 AC 9 ms
5,376 KB
testcase_66 AC 15 ms
5,376 KB
testcase_67 AC 14 ms
5,376 KB
testcase_68 AC 14 ms
5,376 KB
testcase_69 WA -
testcase_70 WA -
testcase_71 WA -
testcase_72 WA -
testcase_73 WA -
testcase_74 WA -
testcase_75 WA -
testcase_76 WA -
testcase_77 WA -
testcase_78 WA -
testcase_79 AC 1 ms
5,376 KB
testcase_80 AC 2 ms
5,376 KB
testcase_81 AC 1 ms
5,376 KB
testcase_82 AC 1 ms
5,376 KB
testcase_83 AC 1 ms
5,376 KB
testcase_84 AC 2 ms
5,376 KB
testcase_85 AC 1 ms
5,376 KB
testcase_86 AC 1 ms
5,376 KB
testcase_87 AC 2 ms
5,376 KB
testcase_88 AC 2 ms
5,376 KB
testcase_89 WA -
testcase_90 WA -
testcase_91 WA -
testcase_92 WA -
testcase_93 WA -
testcase_94 WA -
testcase_95 WA -
testcase_96 WA -
testcase_97 WA -
testcase_98 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int m;
vector<int> h;
class MATH{
public:
	ll powmod (ll a, ll p) {
		ll ans = 1;
		ll mul = a;
		for (; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
			if ((p & 1) == 1) ans = (ans * mul) % MOD;
		}
		return ans;
	}

	ll inverse(ll x) {
		return powmod(x, MOD - 2);
	}

	ll nCr(ll n, ll k) {
	    ll ret = 1;
	    for (ll i = n; i > n - k; i--) {
	        (ret *= i) %= MOD;
	    }
	    for (ll i = k; i >= 1; i--) {
	        (ret *= inverse(i)) %= MOD;
	    }
	    return ret;
	}
};


int main(void){
	cin >> m;
	int t, sum = 0;
	MATH math;
	while(cin >> t){
		h.pb(t);
		sum += t;
	}

	if(h[0] == 0 || h[0] == m){
		printf("1\n");
		return 0;
	}
	if(h.size() + sum - 1 > m){
		printf("NA\n");
		return 0;
	}

	int n = h.size() + (m - (sum + h.size() - 1));
	int k = m - (sum + h.size() - 1);
	printf("%d %d\n", n, k);
	printf("%lld\n", math.nCr(n, k) % MOD);
	return 0;
}
0