QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#738387 | #7056. Chessboard | icpc_zhzx034# | WA | 22ms | 35140kb | C++14 | 1.6kb | 2024-11-12 18:55:57 | 2024-11-12 18:55:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define mkp make_pair
#define pb emplace_back
#define popcnt __builtin_popcountll
const ll mod = 1e9+7;
inline ll read(){
ll x=0, f=1; char ch=getchar();
while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
while(ch>='0' && ch<='9') x=x*10+ch-'0', ch=getchar();
return x*f;
}
inline ll lg2(ll x){ return 63^__builtin_clzll(x); }
inline ll qpow(ll a,ll b){
ll ans=1, base=a;
while(b){
if(b&1) ans=ans*base%mod;
base=base*base%mod; b>>=1;
}
return ans;
}
namespace math{
const ll N = 2000000;
ll fac[N+5],inv[N+5];
ll qpow(ll a,ll b){
ll ans=1,base=a;
while(b){
if(b&1) ans=ans*base%mod;
base=base*base%mod; b>>=1;
}
return ans;
}
void init(){
fac[0]=inv[0]=1;
for(ll i=1;i<=N;i++) fac[i]=fac[i-1]*i%mod;
inv[N]=qpow(fac[N],mod-2);
for(ll i=N-1;i>=1;i--) inv[i]=inv[i+1]*(i+1)%mod;
}
inline ll binom(ll x,ll y){
if(x<0 || y<0 || x<y) return 0;
return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
inline ll perm(ll x,ll y){
if(x<0 || y<0 || x<y) return 0;
return fac[x]*inv[x-y]%mod;
}
}
void init(){ }
ll n,m;
void procedure(){
n=read(), m=read();
if(n==1 || m==1){
puts(n==m?"1":"2");
return;
}
printf("%llu\n", 4ull * math::binom(n+m-2, n-1));
}
int main(){
#ifdef LOCAL
assert(freopen("input.txt","r",stdin));
assert(freopen("output.txt","w",stdout));
#endif
math::init();
ll T=read();
init();
while(T--) procedure();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 15ms
memory: 35136kb
input:
4 1 3 3 2 3 3 4 4
output:
2 12 24 80
result:
ok 4 lines
Test #2:
score: -100
Wrong Answer
time: 22ms
memory: 35140kb
input:
100000 15792 12672 9316 25840 2840 1766 6041 11358 24545 23695 6867 5451 20360 1937 16422 30090 29793 9605 10515 14761 21907 31360 15532 21121 28260 27461 2296 8459 15031 26552 21401 21622 27858 22934 7596 28278 12389 27492 7921 25054 7880 15269 31788 32625 18565 20560 15563 9461 30742 24193 17352 2...
output:
110567924 2924670556 1949970472 966074148 3738866896 850972524 2188501216 3415301012 2348587024 83136096 1868751572 2382630284 2084169268 2853440548 1896111024 2757449236 159729268 1314963632 3123541584 930525180 843770156 720106956 738036168 3297993348 601767944 38907892 3236214848 3455317120 22545...
result:
wrong answer 2nd lines differ - expected: '924670542', found: '2924670556'