結果
問題 | No.117 組み合わせの数 |
ユーザー | Bantako |
提出日時 | 2018-06-04 11:03:10 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,182 bytes |
コンパイル時間 | 1,586 ms |
コンパイル使用メモリ | 170,456 KB |
実行使用メモリ | 18,816 KB |
最終ジャッジ日時 | 2024-06-30 09:33:30 |
合計ジャッジ時間 | 2,629 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
コンパイルメッセージ
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:47: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:43:12: note: 'ans' was declared here 43 | 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)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; cin >> T; rep(i,0,T){ string S,str[2] = {}; cin >> S; char p = S[0]; bool f = 0; for(char c:S){ if(c == ',')f = 1; if(c >= '0' && c <= '9')str[f].push_back(c); } ll ans; if(p == 'P')ans = perm( stoi(str[0]),stoi(str[1]) ); if(p == 'C')ans = combi( stoi(str[0]),stoi(str[1]) ); if(p == 'H')ans = dupc( stoi(str[0]),stoi(str[1]) ); cout << ans << endl; } }