Submission #60325761
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// https://github.com/Pentagon03/Algorithms
// g++ -std=c++20 -D _DEBUG
#ifdef _DEBUG
#define Pentagon03
#include<Pentagon03/debug.h>
#else
#define dbg(...)
#define dbgArr(...)
#endif
#pragma GCC optimize("Ofast", "unroll-loops")
// #pragma GCC target("avx2", "popcnt")
#include"bits/stdc++.h"
// ext headers here: ext/pb_ds/assoc_container.hpp, tr2/dynamic_bitset
using namespace std;
string readline(char delim = '\n'){
cin.ignore();
string t; getline(cin, t, delim);
return move(t);
}
// istringstream iss(s = "1 2 3 4 5"); // iss >> x;
template<typename T> istream& operator>> (istream&in, vector<T>&v){for(auto&x:v)in>>x; return in;}
template<typename T> ostream& operator<< (ostream&out, vector<T>&v){for(auto&x:v)out<<x<<' '; return out;}
auto vec(int n, auto&&... s) {
static_assert(sizeof...(s) >= 1 and "last parameter should be initial value");
if constexpr (sizeof...(s) == 1) return vector (n, s...);
else return vector (n, vec(s...));
}
void assign(auto&A, auto&&n, auto&&...v){
if constexpr(sizeof...(v) == 0) A = n;
else for(int i=0;i<n;i++) assign(A[i], v...);
}
void append(auto&x, auto&&y){x.reserve(x.size()+y.size()), x.insert(x.end(), y.begin(), y.end());}
void addv(auto&v, auto&&...x){(v.push_back(x),...);}
template<typename T> T randint(T l, T r) {static std::mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count()); return std::uniform_int_distribution<T>(l,r)(gen);}
#define all(v) (v).begin(),(v).end()
#define nl '\n'
#define sp ' '
#define rep(i, n) for(int i=0;i<(n);i++)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define repr(i, a, b) for(int i=(a);i<=(b);i++)
#define repd(i, b, a) for(int i=(b);i>=(a);i--)
#define int int64_t
using ll = int64_t; using pii = pair<int,int>; int cur_tc;
constexpr int inf = (int) 1e9 + 3; constexpr ll infl = (ll) 1e18 + 3;
using ld = long double;
int32_t main(){
cin.tie(0)->sync_with_stdio(0); cin.exceptions(ios::badbit | ios::failbit);
cout<<fixed<<setprecision(16);
int tc = 1;
// cin >> tc;
auto solve_tc = [&](){
int n, m; cin >> n >> m;
/*
1번 뽑았을 때
2번 뽑았을 때
3번 뽑았을 때 ...
*/
// p(i): 1번 뽑았을 때 i개 나오기 위한 확률
// dp(i): i개 뽑기 위해서 필요한 기댓값 // dp(0) = 0
// dp(m) = 1 + (p(0)*dp(m) + p(1)*dp(m-1) + ... + (p(m)+...)*dp(0))
// dp(m) * (1-p(0)) = 1 + (p(1)*dp(m-1) + .... (p(m)+...)*dp(0))
vector<ld> P(n); cin >> P;
vector<ld> p(n+1);
p[0] = 1;
// p(i) = (1-t) * p(i) + t * p(i-1)
for(int i=0;i<n;i++){
P[i] /= 100;
vector<ld> np(n+1);
for(int j=0;j<=i+1;j++){
np[j] = (1-P[i]) * p[j];
if(j) np[j] += P[i] * p[j-1];
}
swap(p, np);
}
vector<ld> dp(m+1);
const ld div = 1 - p[0];
for(int i=1;i<=m;i++){
ld sum = 1;
for(int j=1;j<=min(i-1, n); j++)
sum += p[j] * dp[i-j];
dp[i] = sum / div;
}
cout << dp[m] << nl;
};
for(cur_tc=1;cur_tc<=tc;cur_tc++) solve_tc();
return 0;
}
Submission Info
Submission Time
2024-11-30 12:34:47
Task
E - Expansion Packs
User
Pentagon03
Language
C++ 20 (gcc 12.2)
Score
475
Code Size
3297 Byte
Status
AC
Exec Time
94 ms
Memory
4052 KB
Compile Error
Main.cpp: In function ‘std::string readline(char)’:
Main.cpp:18:16: warning: moving a local object in a return statement prevents copy elision [-Wpessimizing-move]
18 | return move(t);
| ~~~~^~~
Main.cpp:18:16: note: remove ‘std::move’ call
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
475 / 475
Status
Set Name
Test Cases
Sample
sample00.txt, sample01.txt, sample02.txt
All
sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt, testcase28.txt, testcase29.txt, testcase30.txt, testcase31.txt
Case Name
Status
Exec Time
Memory
sample00.txt
AC
1 ms
3712 KB
sample01.txt
AC
1 ms
3736 KB
sample02.txt
AC
1 ms
3824 KB
testcase00.txt
AC
78 ms
3988 KB
testcase01.txt
AC
1 ms
4004 KB
testcase02.txt
AC
66 ms
4020 KB
testcase03.txt
AC
1 ms
3828 KB
testcase04.txt
AC
94 ms
4032 KB
testcase05.txt
AC
1 ms
3912 KB
testcase06.txt
AC
78 ms
4040 KB
testcase07.txt
AC
1 ms
3624 KB
testcase08.txt
AC
56 ms
3984 KB
testcase09.txt
AC
67 ms
3960 KB
testcase10.txt
AC
61 ms
4048 KB
testcase11.txt
AC
62 ms
3832 KB
testcase12.txt
AC
2 ms
4000 KB
testcase13.txt
AC
1 ms
3908 KB
testcase14.txt
AC
2 ms
3884 KB
testcase15.txt
AC
1 ms
3872 KB
testcase16.txt
AC
1 ms
3876 KB
testcase17.txt
AC
71 ms
3960 KB
testcase18.txt
AC
1 ms
4000 KB
testcase19.txt
AC
77 ms
3836 KB
testcase20.txt
AC
2 ms
3856 KB
testcase21.txt
AC
78 ms
4016 KB
testcase22.txt
AC
14 ms
3808 KB
testcase23.txt
AC
78 ms
3940 KB
testcase24.txt
AC
14 ms
3944 KB
testcase25.txt
AC
78 ms
4052 KB
testcase26.txt
AC
5 ms
3896 KB
testcase27.txt
AC
77 ms
4052 KB
testcase28.txt
AC
70 ms
4024 KB
testcase29.txt
AC
78 ms
4016 KB
testcase30.txt
AC
18 ms
3872 KB
testcase31.txt
AC
78 ms
3968 KB