結果
問題 |
No.389 ロジックパズルの組み合わせ
|
ユーザー |
![]() |
提出日時 | 2016-07-08 23:06:25 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 593 bytes |
コンパイル時間 | 227 ms |
コンパイル使用メモリ | 23,808 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-13 06:34:46 |
合計ジャッジ時間 | 13,316 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 WA * 3 RE * 95 |
コンパイルメッセージ
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: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]; int i = 0; int sum = 0; while ((scanf("%d", &h[i])) == '\n') { sum += h[i]; i++; } int num = m - sum; num = num - i + 1; if (num < 0) { printf("NA\n"); } else if (num == 0) { printf("1\n"); } else { int fact1 = 1, fact2 = 1, fact3 = 1; for (int j = 1; j <= num + i; j++) { fact1 *= j; } for (int j = 1; j <= i; j++) { fact2 *= j; } for (int j = 1; j <= num; j++) { fact3 *= j; } printf("%d\n", fact1 / (fact2 * fact3)); } return 0; }