Submission #3786048


Source Code Expand

Copy
#include<cstdio>
#include<algorithm>

class Solution{
private :
	static const int maxn = 5e5 + 7;
	static const int maxm = 5e5;
	static const int mod = 998244353;
	
	int n, m, frac[maxn * 2], invf[maxn * 2], ans, tot, sum;
	
	void Init(int x) {
		frac[0] = 1;
		for (register int i = 1; i <= x; i++) {
			frac[i] = 1ll * frac[i - 1] * i % mod;
		}
		invf[x] = Kasumi(frac[x], mod - 2);
		for (register int i = x - 1; i >= 0; i--) {
			invf[i] = 1ll * invf[i + 1] * (i + 1) % mod;
		}
	}
	
	int Kasumi(int a, int b) {
		int res = 1, base = a;
		for (; b; b >>= 1) {
			if (b & 1) {
				res = 1ll * res * base % mod;
			}
			base = 1ll * base * base % mod;
		}
		return res;
	}
	
	int Inv(int x) {
		return Kasumi(x, mod - 2);
	}
	
	int A(int n, int m) {
		if (n == m || !m) {
			return frac[n];
		}
		return 1ll * frac[n] * invf[m] % mod;
	}
	
	int C(int n, int m) {
		if (n == m || !m) {
			return 1;
		}
		return 1ll * A(n, m) * invf[n - m] % mod;
	}
	
public :
	Solution() {
		Get();
		Solve();
	}
	
	void Get() {
		scanf("%d %d", &n, &m);
	}
	
	void Solve() {
        Init(n + m);
        if (n > m) {
            std :: swap(n, m);
        }
        for (register int i = 1; i <= n; i++) {
            tot += 1ll * C(2 * i, i) * C(n - i + m - i, n - i) % mod;
            if (tot >= mod) {
                tot -= mod;
            }
        }
        sum = C(n + m, n);
        printf("%lld\n", (1ll * tot * Inv(sum) % mod * Inv(2) + m) % mod);
	}
};
Solution sol;

int main() {}

Submission Info

Submission Time
Task F - Yes or No
User luogu_bot2
Language C++ (GCC 5.4.1)
Score 2000
Code Size 1483 Byte
Status
Exec Time 23 ms
Memory 7936 KB

Compile Error

./Main.cpp: In member function ‘void Solution::Get()’:
./Main.cpp:59:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &n, &m);
                         ^

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt
Partial 1500 / 1500 sample_01.txt, sample_02.txt, sample_04.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt
All 500 / 500 sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt, subtask_1_19.txt, subtask_1_20.txt, subtask_1_21.txt, subtask_1_22.txt, subtask_1_23.txt, subtask_1_24.txt, subtask_1_25.txt, subtask_2_01.txt, subtask_2_02.txt, subtask_2_03.txt, subtask_2_04.txt, subtask_2_05.txt, subtask_2_06.txt, subtask_2_07.txt, subtask_2_08.txt, subtask_2_09.txt, subtask_2_10.txt, subtask_2_11.txt, subtask_2_12.txt, subtask_2_13.txt, subtask_2_14.txt, subtask_2_15.txt, subtask_2_16.txt, subtask_2_17.txt, subtask_2_18.txt, subtask_2_19.txt, subtask_2_20.txt, subtask_2_21.txt, subtask_2_22.txt, subtask_2_23.txt, subtask_2_24.txt, subtask_2_25.txt, subtask_2_26.txt, subtask_2_27.txt, subtask_2_28.txt, subtask_2_29.txt, subtask_2_30.txt, subtask_2_31.txt, subtask_2_32.txt, subtask_2_33.txt, subtask_2_34.txt, subtask_2_35.txt, subtask_2_36.txt, subtask_2_37.txt, subtask_2_38.txt, subtask_2_39.txt, subtask_2_40.txt
Case Name Status Exec Time Memory
sample_01.txt 1 ms 2176 KB
sample_02.txt 1 ms 2176 KB
sample_03.txt 1 ms 2176 KB
sample_04.txt 1 ms 2176 KB
sample_05.txt 1 ms 2176 KB
subtask_1_01.txt 1 ms 2176 KB
subtask_1_02.txt 1 ms 2176 KB
subtask_1_03.txt 1 ms 2176 KB
subtask_1_04.txt 1 ms 2176 KB
subtask_1_05.txt 1 ms 2176 KB
subtask_1_06.txt 1 ms 2176 KB
subtask_1_07.txt 1 ms 2176 KB
subtask_1_08.txt 1 ms 2176 KB
subtask_1_09.txt 1 ms 2176 KB
subtask_1_10.txt 1 ms 2176 KB
subtask_1_11.txt 1 ms 2176 KB
subtask_1_12.txt 1 ms 2176 KB
subtask_1_13.txt 1 ms 2304 KB
subtask_1_14.txt 3 ms 4480 KB
subtask_1_15.txt 6 ms 4992 KB
subtask_1_16.txt 6 ms 4992 KB
subtask_1_17.txt 6 ms 4992 KB
subtask_1_18.txt 6 ms 4992 KB
subtask_1_19.txt 6 ms 4992 KB
subtask_1_20.txt 6 ms 4992 KB
subtask_1_21.txt 6 ms 4992 KB
subtask_1_22.txt 6 ms 4992 KB
subtask_1_23.txt 6 ms 4992 KB
subtask_1_24.txt 5 ms 4992 KB
subtask_1_25.txt 5 ms 4992 KB
subtask_2_01.txt 1 ms 2176 KB
subtask_2_02.txt 1 ms 2176 KB
subtask_2_03.txt 1 ms 2176 KB
subtask_2_04.txt 23 ms 7936 KB
subtask_2_05.txt 23 ms 7936 KB
subtask_2_06.txt 23 ms 7936 KB
subtask_2_07.txt 23 ms 7936 KB
subtask_2_08.txt 23 ms 7936 KB
subtask_2_09.txt 23 ms 7936 KB
subtask_2_10.txt 23 ms 7936 KB
subtask_2_11.txt 23 ms 7936 KB
subtask_2_12.txt 23 ms 7936 KB
subtask_2_13.txt 23 ms 7936 KB
subtask_2_14.txt 23 ms 7936 KB
subtask_2_15.txt 23 ms 7936 KB
subtask_2_16.txt 23 ms 7936 KB
subtask_2_17.txt 22 ms 7936 KB
subtask_2_18.txt 21 ms 7680 KB
subtask_2_19.txt 18 ms 7168 KB
subtask_2_20.txt 8 ms 6272 KB
subtask_2_21.txt 8 ms 6272 KB
subtask_2_22.txt 8 ms 6272 KB
subtask_2_23.txt 8 ms 6272 KB
subtask_2_24.txt 8 ms 6272 KB
subtask_2_25.txt 8 ms 6272 KB
subtask_2_26.txt 8 ms 6272 KB
subtask_2_27.txt 8 ms 6272 KB
subtask_2_28.txt 9 ms 6272 KB
subtask_2_29.txt 9 ms 6272 KB
subtask_2_30.txt 11 ms 6400 KB
subtask_2_31.txt 14 ms 6784 KB
subtask_2_32.txt 23 ms 7936 KB
subtask_2_33.txt 23 ms 7936 KB
subtask_2_34.txt 23 ms 7936 KB
subtask_2_35.txt 23 ms 7936 KB
subtask_2_36.txt 22 ms 7936 KB
subtask_2_37.txt 11 ms 6144 KB
subtask_2_38.txt 8 ms 5888 KB
subtask_2_39.txt 22 ms 7808 KB
subtask_2_40.txt 11 ms 6400 KB