結果
| 問題 |
No.1662 (ox) Alternative
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-01-12 15:58:46 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 62 ms / 2,000 ms |
| コード長 | 970 bytes |
| コンパイル時間 | 2,332 ms |
| コンパイル使用メモリ | 193,856 KB |
| 実行使用メモリ | 8,448 KB |
| 最終ジャッジ日時 | 2025-01-12 15:58:50 |
| 合計ジャッジ時間 | 3,371 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:35:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
35 | scanf("%d", &cases);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:39:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%d%d%d%d", &a, &b, &c, &d);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using LL = long long;
const int N = 4e5 + 7;
const int MOD = 1e9 + 7;
int fac[N], ifc[N], inv[N];
int pow(int x, int y) {
int ret = 1;
while(y) {
if(y & 1)
ret = 1LL * ret * x % MOD;
x = 1LL * x * x % MOD;
y >>= 1;
}
return ret;
}
int com(int x, int y) {
return 1LL * fac[x] * ifc[y] % MOD * ifc[x - y] % MOD;
}
int main() {
fac[0] = ifc[0] = fac[1] = ifc[1] = inv[1] = 1;
for(int i = 2; i < N; ++i) {
fac[i] = 1LL * fac[i - 1] * i % MOD;
inv[i] = MOD - 1LL * (MOD / i) * inv[MOD % i] % MOD;
ifc[i] = 1LL * ifc[i - 1] * inv[i] % MOD;
}
int cases;
scanf("%d", &cases);
while(cases--) {
int a, b, c, d;
scanf("%d%d%d%d", &a, &b, &c, &d);
if(a != b)
puts("0");
else if(a == 0)
printf("%d\n", !d);
else
printf("%lld\n", 1LL * inv[a] * com(a + b + c + d, c) % MOD *
com(a + d - 1, d) % MOD * com(2 * a + d, a - 1) % MOD);
}
return 0;
}