第 45 届国际大学生程序设计竞赛(ICPC)亚洲网上区域赛模拟赛
A Easy Equation
#include <bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
void solve() {
int a,b,c,d;
cin>>a>>b>>c>>d;
int sum=min(a+b,d),ans=0;
for (int i = 0; i <= sum; ++i) {
ans+=(min(a,i)-max(i-b,0ll)+1)*(min(d-i,c)+1);
}
cout<<ans<<"\n";
}
signed main() {
int _ = 1;
while (_--) {
solve();
}
return 0;
}
B XTL’s Chessboard
#include <bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
void solve() {
cout<<2;
}
signed main() {
int _ = 1;
while (_--) {
solve();
}
return 0;
}
D Pokemon Ultra Sun
#include <bits/stdc++.h>
#define int ll
using namespace std;
typedef long long ll;
const int maxn = 3e3 + 10;
double dp[maxn][maxn];
void solve() {
int hp1, hp2, w;
double p;
cin >> hp1 >> hp2 >> w >> p;
memset(dp,0,sizeof(dp));
for (int i = 1; i <= hp1; ++i) {
for (int j = 1; j <= hp2; j++) {
dp[i][j] = dp[max(0ll,i-w)][j]*(1-p) + dp[i][max(j-w,0ll)]*p+1.0;
}
}
printf("%.6f\n",dp[hp1][hp2]);
}
signed main() {
int _ = 1;
cin >> _;
while (_--) {
solve();
}
return 0;
}