結果
| 問題 |
No.389 ロジックパズルの組み合わせ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-22 19:33:05 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 392 bytes |
| コンパイル時間 | 675 ms |
| コンパイル使用メモリ | 65,460 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-09 20:45:12 |
| 合計ジャッジ時間 | 5,008 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 94 WA * 5 |
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
5 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
long mod=1e9+7;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
main()
{
int M;cin>>M;
int s=0,c=0;
for(int h;cin>>h;c++)s+=h;
if(s+c-1>M)
{
cout<<"NA"<<endl;
return 0;
}
long a=1,b=1;
int N=c+1,K=M-(s+c-1);
N+=K-1;
for(long i=1;i<=K;i++)
{
a=a*(N-i+1)%mod;
b=b*i%mod;
}
cout<<a*power(b,mod-2)%mod<<endl;
}