From e04a08e502431d26ffcde2784a7c28fb270ac8b1 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Fri, 22 Aug 2025 12:08:58 +0800 Subject: [PATCH] update --- src/8/22/P1297.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/8/22/P1297.cpp b/src/8/22/P1297.cpp index 294989d..9cb59f0 100644 --- a/src/8/22/P1297.cpp +++ b/src/8/22/P1297.cpp @@ -1,3 +1,29 @@ -int main(){ - -} \ No newline at end of file +#include +#include +#include +#include + +#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 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); +}