QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#43064#2964. Loot Chestsinbad#AC ✓2ms3888kbC++3.9kb2022-08-06 10:16:102022-08-06 10:16:12

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-06 10:16:12]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:3888kb
  • [2022-08-06 10:16:10]
  • 提交

answer

#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const multiset<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

template <class T> auto vect(const T& v, int n) { return vector<T>(n, v); }
template <class T, class... D> auto vect(const T& v, int n, D... m) {
  return vector<decltype(vect(v, m...))>(n, vect(v, m...));
}

using int64 = long long;
using int128 = __int128_t;
using ii = pair<int, int>;
#define SZ(x) (int)((x).size())
template <typename T> static constexpr T inf = numeric_limits<T>::max() / 2;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
mt19937_64 mrand(random_device{}());
int64 rnd(int64 x) { return mrand() % x; }
int lg2(int64 x) { return sizeof(int64) * 8 - 1 - __builtin_clzll(x); }
template <class T> void out(const vector<T>& a) { for (int i = 0; i < SZ(a); ++i) cout << a[i] << " \n"[i + 1 == SZ(a)]; }
template <class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template <class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template <class T> void dedup(vector<T>& v) { sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end()); }
void add_mod(int& x, int y) { x += y; if (x >= MOD) x -= MOD; }
void sub_mod(int& x, int y) { x += MOD - y; if (x >= MOD) x -= MOD; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  int dL, dW;
  double G, L, W;
  cin >> dL >> dW >> G >> L;
  L /= 100; G /= 100;
  W = 1 - L;

  vector<double> dp(101);
  dp[100] = 1 / W;
  for (int i = 99; i >= 0; --i) {
    int x = min(i + dW, 100);
    int y = min(i + dL, 100);
    dp[i] = 1 + W * ((100 - i) / 100.0 * dp[x]) + L * dp[y];
  }
  cout << dp[0] / G << '\n';
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3864kb

input:

1 100 50 0

output:

4.0000000000

result:

ok found '4.0000000', expected '4.0000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3696kb

input:

50 50 100 25

output:

2.8333333333

result:

ok found '2.8333333', expected '2.8333333', error '0.0000000'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3708kb

input:

1 100 10 0

output:

20.0000000000

result:

ok found '20.0000000', expected '20.0000000', error '0.0000000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3696kb

input:

2 3 10 80

output:

197.0057067200

result:

ok found '197.0057067', expected '197.0057067', error '0.0000000'

Test #5:

score: 0
Accepted
time: 2ms
memory: 3820kb

input:

1 1 100 0

output:

13.2099606302

result:

ok found '13.2099606', expected '13.2099606', error '0.0000000'

Test #6:

score: 0
Accepted
time: 0ms
memory: 3772kb

input:

1 100 100 0

output:

2.0000000000

result:

ok found '2.0000000', expected '2.0000000', error '0.0000000'

Test #7:

score: 0
Accepted
time: 2ms
memory: 3768kb

input:

1 1 1 0

output:

1320.9960630216

result:

ok found '1320.9960630', expected '1320.9960630', error '0.0000000'

Test #8:

score: 0
Accepted
time: 2ms
memory: 3784kb

input:

1 2 1 99

output:

14648.6536175788

result:

ok found '14648.6536176', expected '14648.6536176', error '0.0000000'

Test #9:

score: 0
Accepted
time: 2ms
memory: 3772kb

input:

100 100 1 1

output:

201.0101010101

result:

ok found '201.0101010', expected '201.0101010', error '0.0000000'

Test #10:

score: 0
Accepted
time: 2ms
memory: 3832kb

input:

1 3 1 49

output:

1326.8939535845

result:

ok found '1326.8939536', expected '1326.8939536', error '0.0000000'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3768kb

input:

69 91 78 18

output:

3.0116823014

result:

ok found '3.0116823', expected '3.0116823', error '0.0000000'

Test #12:

score: 0
Accepted
time: 2ms
memory: 3768kb

input:

40 13 94 9

output:

4.3387976566

result:

ok found '4.3387977', expected '4.3387977', error '0.0000000'

Test #13:

score: 0
Accepted
time: 2ms
memory: 3692kb

input:

88 43 61 71

output:

7.7139131837

result:

ok found '7.7139132', expected '7.7139132', error '0.0000000'

Test #14:

score: 0
Accepted
time: 2ms
memory: 3772kb

input:

13 46 56 40

output:

6.7900497905

result:

ok found '6.7900498', expected '6.7900498', error '0.0000000'

Test #15:

score: 0
Accepted
time: 2ms
memory: 3868kb

input:

79 82 27 70

output:

16.7938271605

result:

ok found '16.7938272', expected '16.7938272', error '0.0000000'

Test #16:

score: 0
Accepted
time: 2ms
memory: 3688kb

input:

62 57 67 33

output:

4.3373691245

result:

ok found '4.3373691', expected '4.3373691', error '0.0000000'

Test #17:

score: 0
Accepted
time: 1ms
memory: 3836kb

input:

3 1 1 97

output:

4951.7562469227

result:

ok found '4951.7562469', expected '4951.7562469', error '0.0000000'

Test #18:

score: 0
Accepted
time: 2ms
memory: 3752kb

input:

1 2 54 50

output:

28.3239197602

result:

ok found '28.3239198', expected '28.3239198', error '0.0000000'

Test #19:

score: 0
Accepted
time: 2ms
memory: 3820kb

input:

2 3 6 1

output:

132.8312852692

result:

ok found '132.8312853', expected '132.8312853', error '0.0000000'

Test #20:

score: 0
Accepted
time: 2ms
memory: 3888kb

input:

2 3 34 2

output:

23.5899851154

result:

ok found '23.5899851', expected '23.5899851', error '0.0000000'

Test #21:

score: 0
Accepted
time: 2ms
memory: 3780kb

input:

66 63 52 38

output:

5.7144292804

result:

ok found '5.7144293', expected '5.7144293', error '0.0000000'

Test #22:

score: 0
Accepted
time: 2ms
memory: 3888kb

input:

62 46 75 27

output:

3.8529123916

result:

ok found '3.8529124', expected '3.8529124', error '0.0000000'

Test #23:

score: 0
Accepted
time: 2ms
memory: 3828kb

input:

65 18 37 17

output:

9.4908434032

result:

ok found '9.4908434', expected '9.4908434', error '0.0000000'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

97 13 80 32

output:

4.4304809781

result:

ok found '4.4304810', expected '4.4304810', error '0.0000000'