結果
| 問題 |
No.389 ロジックパズルの組み合わせ
|
| コンテスト | |
| ユーザー |
yoshinari1110
|
| 提出日時 | 2016-07-08 23:13:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 678 bytes |
| コンパイル時間 | 220 ms |
| コンパイル使用メモリ | 24,064 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-13 06:38:21 |
| 合計ジャッジ時間 | 14,163 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 5 RE * 93 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:25: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
9 | while ((scanf("%d", &h[i])) == '\n') {
| ~^ ~~~~~
| | |
| | long long int*
| int*
| %lld
main.cpp:33:26: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
33 | printf("%d\n", (fact1 / (fact2 * fact3)) % 1000000007);
| ~^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| int long long int
| %lld
main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
5 | scanf("%lld", &m);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <cstdio>
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 ((scanf("%d", &h[i])) == '\n') {
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;
for (long long int j = 1; j <= num + i; j++) {
fact1 *= j;
}
for (long long int j = 1; j <= i; j++) {
fact2 *= j;
}
for (long long int j = 1; j <= num; j++) {
fact3 *= j;
}
printf("%d\n", (fact1 / (fact2 * fact3)) % 1000000007);
}
return 0;
}
yoshinari1110