QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#663685#7056. ChessboardLoxilanteAC ✓63ms13936kbC++141.3kb2024-10-21 16:44:402024-10-21 16:44:40

Judging History

你现在查看的是最新测评结果

  • [2024-10-21 16:44:40]
  • 评测
  • 测评结果:AC
  • 用时:63ms
  • 内存:13936kb
  • [2024-10-21 16:44:40]
  • 提交

answer

#define F_C
#include <bits/stdc++.h>
#define rep(i, l, r) for(int i = l; i < r; i++)
#define hrp(i, l, r) for(int i = l; i <= r; i++)
#define rev(i, r, l) for(int i = r; i >= l; i--)
#define int ll
using namespace std;
typedef long long ll;
template<typename tn = int> tn next(void) { tn k; cin>>k; return k; }
#ifndef LOCAL
#define D(...) 0
#endif
const int U = 1e6+100;
const int MOD = 1000000007;
int fac[2*U], ifa[2*U];
int quickPow(int a, int b)
{
	int ret = 1%MOD, t = a;
	while(b)
	{
		if (b & 1) ret = ret*t%MOD;
		t = t*t%MOD;
		b >>= 1;
	}
	return ret;
}
int inv(int x)
{
	return quickPow(x, MOD-2);
}
int C(int n, int m)
{
    return fac[n]*inv(fac[m])%MOD*inv(fac[n-m])%MOD;
}
signed main(void)
{
    #ifdef LOCAL
//	freopen("C:\\Users\\Loxil\\Desktop\\IN.txt", "r", stdin);
//	freopen("C:\\Users\\Loxil\\Desktop\\OUT.txt", "w", stdout);
    #endif

    D(inv(12345));
    
    ios::sync_with_stdio(false);
    cin.tie(0);

    fac[1] = 1;
    rep(i, 2, 1e6+10) fac[i] = fac[i-1]*i%MOD;
    
    int T = next();
    while(T--)
    {
        int n, m;
        cin>>n>>m;
        if (n+m == 2) cout<<1<<endl;
        else if (n == 1 || m == 1) cout<<2<<endl;
        else cout<<4*C(n+m-2, n-1)%MOD<<endl;
    }
    
    return 0;
}
/*

 */

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 6ms
memory: 13932kb

input:

4
1 3
3 2
3 3
4 4

output:

2
12
24
80

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 63ms
memory: 13936kb

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
924670542
949970465
966074148
738866875
850972524
188501202
415300991
348587010
83136096
868751565
382630270
84169254
853440534
896111017
757449222
159729268
314963625
123541563
930525180
843770156
720106956
738036168
297993327
601767944
38907892
236214827
455317099
254577850
272370955
239...

result:

ok 100000 lines