結果
| 問題 |
No.1683 Robot Guidance
|
| コンテスト | |
| ユーザー |
inksamurai
|
| 提出日時 | 2021-09-18 01:14:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 416 ms / 2,000 ms |
| コード長 | 2,511 bytes |
| コンパイル時間 | 1,555 ms |
| コンパイル使用メモリ | 171,592 KB |
| 実行使用メモリ | 19,388 KB |
| 最終ジャッジ日時 | 2024-06-29 23:59:30 |
| 合計ジャッジ時間 | 7,407 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
#include <bits/stdc++.h>
//eolibraries
#define lnf 3999999999999999999
#define inf 999999999
#define fi first
#define se second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end());
#define rep(i,n) for(int i=0;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define vec(...) vector<__VA_ARGS__>
#define _3E8xdS5 ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//eodefine
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<int,int>;
using vi=vec(int);
using vll=vec(ll);
const int mxn=2e6;
//snuke's modular int
template <ll mod>
struct modularint{
ll x;
modularint(ll x=0):x(x%mod){}
modularint& operator+=(const modularint a){
if ((x += a.x) >= mod) x -= mod;
return *this;
}
modularint& operator-=(const modularint a){
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
modularint& operator*=(const modularint a){
(x *= a.x) %= mod;
return *this;
}
modularint operator+(const modularint a)const{
modularint res(*this);
return res+=a;
}
modularint operator-(const modularint a)const{
modularint res(*this);
return res-=a;
}
modularint operator*(const modularint a)const{
modularint res(*this);
return res*=a;
}
modularint pow(ll n)const{
modularint res=1,x(*this);
while(n){
if(n&1)res*=x;
x*=x;
n>>=1;
}
return res;
}
modularint inv()const{
return pow(mod-2);
}
};
using mint=modularint<1000000007>;
mint fact[mxn+10];
void prefact(){
fact[0]=fact[1]=1;
crep(i,2,mxn){
mint x=i;
fact[i]=fact[i-1]*x;
}
}
mint cnk(ll k,ll n){
if(k>n) return 0;
mint e=fact[k]*fact[n-k];
return fact[n] * e.inv();
}
int main(){
_3E8xdS5;
prefact();
int a,b,x,y;
cin>>a>>b>>x>>y;
vi rbts;
rep(i,4){
rbts.pb(b/4);
}
int z=b%4;
rep(i,z+1){
rbts[i]++;
}
mint ans=0;
rep(i,a+1){
vi nowrbts(4);
nowrbts[0]=i;
nowrbts[2]=(i-x);
ll j=a-(nowrbts[0]+nowrbts[2]);
if(nowrbts[1]<0) continue;
if((j-y)%2) continue;
ll yl=(j-y)/2,yr=(y+yl);
if(min(yl,yr)<0) continue;
if(yr-yl!=y) continue;
nowrbts[3]=yl;
nowrbts[1]=yr;
mint now=1;
rep(j,4){
if(rbts[j]==0 and nowrbts[j]>0){
// cout<<j<<"\n";
now=0;
break;
}else if(rbts[j]==0 and nowrbts[j]==0){
}else{
now*=cnk(rbts[j]-1,nowrbts[j]+rbts[j]-1);
}
}
ans+=now;
// printf("\n");
}
printf("%lld\n",ans.x);
// let's fix positive x-es
return 0;
}
inksamurai