mirror of
https://gitcode.com/Zengtudor/alg2025.git
synced 2025-12-22 07:01:46 +00:00
Compare commits
No commits in common. "e04a08e502431d26ffcde2784a7c28fb270ac8b1" and "78bac3ae8a361a2236cad60214c918ef476bc411" have entirely different histories.
e04a08e502
...
78bac3ae8a
@ -1,14 +0,0 @@
|
||||
/*
|
||||
假设一个随机数生成器每次随机一个数[1,n],形成一个无限长的字符串s,
|
||||
给定一个长度为m的数,那么第一次在s中出现位置的期望是多少
|
||||
|
||||
n=2 12 的位置
|
||||
e[1]=1/2*1+1/2*(e[1]+1)
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
int main(){
|
||||
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
#define long long long
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
ios_base::sync_with_stdio(false);
|
||||
cin.tie(NULL);
|
||||
int n;
|
||||
long A, B, C;
|
||||
vector<long> a(10000001);
|
||||
scanf("%d%lld%lld%lld%ld", &n, &A, &B, &C, &a[1]);
|
||||
for (int i = 2; i <= n; ++i) {
|
||||
a[i] = (a[i - 1] * A + B) % 100000001;
|
||||
}
|
||||
for (int i = 1; i <= n; ++i) {
|
||||
a[i] = a[i] % C + 1;
|
||||
}
|
||||
double exp = 0.0;
|
||||
for (int i = 2; i <= n; ++i) {
|
||||
exp += (double)min(a[i - 1], a[i]) / (double)(a[i - 1] * a[i]);
|
||||
}
|
||||
exp += (double)min(a[n], a[1]) / (double)(a[n] * a[1]);
|
||||
printf("%.3f\n", exp);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user