結果

問題 No.117 組み合わせの数
ユーザー koba-e964koba-e964
提出日時 2016-10-17 16:35:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 194 ms / 5,000 ms
コード長 416 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 23,680 KB
実行使用メモリ 17,920 KB
最終ジャッジ日時 2024-05-02 03:10:56
合計ジャッジ時間 1,142 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 194 ms
17,920 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |                                                                                                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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);
}
0