2024 ICPC武汉邀请赛暨湖北省赛 题解
Dashboard - The 2024 International Collegiate Programming Contest in Hubei Province, China - Codeforces
题目难度(过题):E A J / B L H G F K 睡醒补
榜单含打星队仅供参考
铜牌:4 321
银牌:5 419
金牌:9 1119
Problem - E - Codeforces
题意:加法。
// Code Start Here int t;cin >> t;while(t--){int n , x , a , b;cin >> n >> x >> a >> b;cout << x * b + (n - x) * a <<endl;}
Problem - A - Codeforces
思路:我们考虑这样去最大化a , b:
对于的值是固定的,我们扩大b,减小a可以达到使a *b更大的效果。比如 4 * sqrt ( 1)和1 * sqrt(16) 都是4
所以我们直接让a = 1,b就是原式。
// Code Start Here int t;cin >> t;while(t--){int x , y;cin >> x >> y;cout << 1 << " " << lcm(x , y) / gcd(x , y) << endl;}
Problem - J - Codeforces
思路:可以发现最后一定和平均数有关,考虑如何求分母,使用逆模运算即可
// Code Start Here int n;cin >> n;int sum = 0;for(int i = 1;i<=n;i++){int x;cin >> x;sum += x;sum %= mod;}auto mod_pow = [&](int a ,int b)->int{int res = 1;a %= mod;while(b > 0){if(b & 1)res = res * a % mod;a = a * a % mod;b >>= 1;}return res;};int inv = mod_pow(n , mod - 2);int ans = (sum * inv) % mod;cout << ans << endl;