結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー yoshinari1110yoshinari1110
提出日時 2016-07-08 23:46:44
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 797 bytes
コンパイル時間 627 ms
コンパイル使用メモリ 54,516 KB
実行使用メモリ 7,300 KB
最終ジャッジ日時 2024-04-21 08:40:20
合計ジャッジ時間 3,580 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 6 ms
6,940 KB
testcase_13 AC 26 ms
6,944 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 47 ms
6,964 KB
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 52 ms
6,968 KB
testcase_50 AC 5 ms
6,944 KB
testcase_51 AC 4 ms
6,940 KB
testcase_52 AC 11 ms
6,944 KB
testcase_53 AC 6 ms
6,940 KB
testcase_54 AC 13 ms
6,940 KB
testcase_55 AC 2 ms
6,944 KB
testcase_56 AC 6 ms
6,944 KB
testcase_57 AC 22 ms
6,940 KB
testcase_58 AC 42 ms
6,944 KB
testcase_59 AC 33 ms
6,940 KB
testcase_60 AC 16 ms
6,940 KB
testcase_61 AC 68 ms
7,300 KB
testcase_62 AC 16 ms
6,940 KB
testcase_63 AC 44 ms
6,944 KB
testcase_64 AC 13 ms
6,940 KB
testcase_65 AC 8 ms
6,944 KB
testcase_66 AC 14 ms
6,944 KB
testcase_67 AC 14 ms
6,940 KB
testcase_68 AC 14 ms
6,944 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
6,940 KB
testcase_80 AC 1 ms
6,940 KB
testcase_81 AC 2 ms
6,944 KB
testcase_82 AC 2 ms
6,940 KB
testcase_83 AC 2 ms
6,944 KB
testcase_84 AC 1 ms
6,944 KB
testcase_85 AC 1 ms
6,940 KB
testcase_86 AC 2 ms
6,940 KB
testcase_87 AC 2 ms
6,940 KB
testcase_88 AC 2 ms
6,948 KB
testcase_89 AC 18 ms
6,940 KB
testcase_90 AC 29 ms
6,944 KB
testcase_91 AC 49 ms
6,940 KB
testcase_92 AC 8 ms
6,944 KB
testcase_93 AC 31 ms
6,944 KB
testcase_94 AC 2 ms
6,944 KB
testcase_95 AC 33 ms
6,944 KB
testcase_96 AC 26 ms
6,944 KB
testcase_97 AC 25 ms
6,940 KB
testcase_98 AC 14 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%lld", &m);
      |         ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <iostream>
using namespace std;

int main() {
	long long int m;
	scanf("%lld", &m);
	long long int *h = new long long int[m];
	long long int i = 0;
	long long int sum = 0;
	while (cin >> h[i]) {
		sum += h[i];
		i++;
	}
	long long int num = m - sum;
	num = num - i + 1;
	if (num < 0) {
		printf("NA\n");
	}
	else if (num == 0) {
		printf("1\n");
	}
	else {
		long long int fact1 = 1, fact2 = 1, fact3 = 1;
		long long int j = 1;
		for (j = 0; j < num + i; j++) {
			fact1 = (fact1 * (j + 1)) % 1000000007;
		}

		for (j = 0; j < i; j++) {
			fact2 = (fact2 * (j + 1)) % 1000000007;
		}

		for (j = 0; j < num; j++) {
			fact3 = (fact3 * (j + 1)) % 1000000007;
		}
		fact2 = (fact2 * fact3) % 1000000007;
		printf("%lld\n", (fact1 / fact2) % 1000000007);
	}

	return 0;
}
0