結果
| 問題 |
No.117 組み合わせの数
|
| ユーザー |
Bantako
|
| 提出日時 | 2018-06-04 11:32:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 988 bytes |
| コンパイル時間 | 1,595 ms |
| コンパイル使用メモリ | 170,068 KB |
| 実行使用メモリ | 18,976 KB |
| 最終ジャッジ日時 | 2024-06-30 09:33:48 |
| 合計ジャッジ時間 | 2,550 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 1 |
コンパイルメッセージ
main.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
28 | main(){
| ^~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:39,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
from main.cpp:1:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]',
inlined from 'int main()' at main.cpp:42:17:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:202:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
202 | { return _M_insert(__n); }
| ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:38:12: note: 'ans' was declared here
38 | ll ans;
| ^~~
ソースコード
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
vector<ll> fact(2000010);
ll powmod(ll x,ll n){
if(n == 0)return 1;
ll ans = powmod(x*x%MOD,n/2);
if(n % 2)ans = ans * x % MOD;
return ans;
}
ll divmod(ll a,ll b){
return ((a%MOD) * (powmod(b,MOD-2)%MOD)) % MOD;
}
ll perm(ll n,ll r){
if(n < r)return 0;
return divmod( fact[n] , fact[n-r]);
}
ll combi(ll n,ll r){
if(n < r || n < 0)return 0;
return divmod( perm(n,r) , fact[r]);
}
ll dupc(ll n,ll r){
return combi(n+r-1,r);
}
main(){
fact[0] = 1;
rep(i,1,2000010)fact[i] = fact[i-1] * i % MOD;
ll T;
scanf("%lld",&T);
rep(i,0,T){
char c;
int a,b;
scanf(" %c(%d,%d)",&c ,&a ,&b);
ll ans;
if(c == 'P')ans = perm(a,b);
if(c == 'C')ans = combi(a,b);
if(c == 'H')ans = dupc(a,b);
cout << ans << endl;
}
}
Bantako