結果
問題 | No.520 プロジェクトオイラーへの招待 |
ユーザー |
![]() |
提出日時 | 2020-01-21 21:39:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 126 ms / 4,000 ms |
コード長 | 1,790 bytes |
コンパイル時間 | 1,009 ms |
コンパイル使用メモリ | 114,244 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-06 06:20:16 |
合計ジャッジ時間 | 1,752 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 7 |
ソースコード
#include <cstdio>#include <cstring>#include <iostream>#include <string>#include <cmath>#include <bitset>#include <vector>#include <map>#include <set>#include <queue>#include <deque>#include <algorithm>#include <complex>#include <unordered_map>#include <unordered_set>#include <random>#include <cassert>#include <fstream>#include <utility>#include <functional>#include <time.h>#include <stack>#include <array>#define popcount __builtin_popcountusing namespace std;typedef long long int ll;typedef pair<int, int> P;const ll MOD=1e9+7;ll powmod(ll a, ll k){ll ap=a, ans=1;while(k){if(k&1){ans*=ap;ans%=MOD;}ap=ap*ap;ap%=MOD;k>>=1;}return ans;}ll inv(ll a){return powmod(a, MOD-2);}ll f[220], invf[220];void fac(int n){f[0]=1;for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;invf[n]=inv(f[n]);for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;}ll comb(int x, int y){if(!(0<=y && y<=x)) return 0;return f[x]*invf[y]%MOD*invf[x-y]%MOD;}int main(){fac(210);int n;cin>>n;for(int z=0; z<n; z++){int a, b, c;cin>>a>>b>>c;ll ans=0;for(int i=0; i<a; i++){for(int j=0; j<b; j++){for(int k=0; k<c; k++){(ans+=comb(i+c-1-k, i)*comb(j+a-1-i, j)%MOD*comb(k+b-1-j, k))%=MOD;}}}for(int i=0; i<a; i++){for(int j=i; j<a; j++){(ans+=comb(i+c-1, c-1)*comb(a-1-j+b-1, b-1))%=MOD;}}for(int i=0; i<b; i++){for(int j=i; j<b; j++){(ans+=comb(i+a-1, a-1)*comb(b-1-j+c-1, c-1))%=MOD;}}for(int i=0; i<c; i++){for(int j=i; j<c; j++){(ans+=comb(i+b-1, b-1)*comb(c-1-j+a-1, a-1))%=MOD;}}cout<<ans<<endl;}return 0;}