結果
| 問題 | No.117 組み合わせの数 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-17 16:35:10 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 188 ms / 5,000 ms |
| コード長 | 416 bytes |
| 記録 | |
| コンパイル時間 | 369 ms |
| コンパイル使用メモリ | 23,936 KB |
| 実行使用メモリ | 17,920 KB |
| 最終ジャッジ日時 | 2024-11-22 13:20:48 |
| 合計ジャッジ時間 | 1,144 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:12:12: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | for(scanf("%lld",&t);t--;printf("%lld\n",c%2?b(n,k):c%5?(n?b(n+k-1,k):!k):n>=k?f[n]*r(f[n-k])%m:0))scanf("%*[\n]%c(%lld,%lld)",&c,&n,&k);
| ~~~~~^~~~~~~~~~~
main.cpp:12:107: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | for(scanf("%lld",&t);t--;printf("%lld\n",c%2?b(n,k):c%5?(n?b(n+k-1,k):!k):n>=k?f[n]*r(f[n-k])%m:0))scanf("%*[\n]%c(%lld,%lld)",&c,&n,&k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
typedef long long ll;
ll m=1e9+7,f[1<<21],n,k,t,s,u,e;char c;
ll r(ll v){
for(e=m-2,s=1,u=v%m;e;u=u*u%m,e/=2)if(e%2)s=s*u%m;
return s;
}
ll b(ll n,ll k){
return n<k?0:f[n]*r(f[k])%m*r(f[n-k])%m;}
int main(){
for(f[t=0]=1;++t<1<<21;f[t]=f[t-1]*t%m);
for(scanf("%lld",&t);t--;printf("%lld\n",c%2?b(n,k):c%5?(n?b(n+k-1,k):!k):n>=k?f[n]*r(f[n-k])%m:0))scanf("%*[\n]%c(%lld,%lld)",&c,&n,&k);
}