QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#54995 | #2964. Loot Chest | abdelrahman001# | TL | 0ms | 0kb | C++ | 941b | 2022-10-11 21:07:14 | 2022-10-11 21:07:15 |
Judging History
answer
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 5e5 + 5;
ld dl, dw, g, l;
ld memo[N][105];
ld solve(int day, int p) {
if(day == N)
return 0;
ld &ans = memo[day][p];
if(ans != -1)
return ans;
ans = solve(day + 1, min((ld)100, p + dl)) * l / 100;
ans += solve(day + 1, min((ld)100, p + dw)) * ((100 - l) / 100) * ((ld)(100 - p) / 100);
ans += ((ld)p / 100) * ((100 - l) / 100) * ((g * day / 100) + solve(day + 1, 0) * (100 - g) / 100);
return ans;
}
int main() {
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin >> dl >> dw >> g >> l;
for(int i = 0;i < N;i++) {
for(int j = 0;j <= 100;j++)
memo[i][j] = -1;
}
cout << fixed << setprecision(9) << solve(1, 0);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
1 100 50 0