Skip to content

Commit

Permalink
20241030 md's submission for cf621c (#8022)
Browse files Browse the repository at this point in the history
  • Loading branch information
mengdiwang authored Oct 31, 2024
1 parent dc21c97 commit ac8c20e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions daily_problems/2024/10/1030/personal_submission/cf621c_md.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// 1030
#include <bits/stdc++.h>
using i64 = long long;

int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);

int n, p;
std::cin >> n >> p;
std::vector<double> probs(n);
for (int i = 0; i < n; ++i) {
int left, right;
std::cin >> left >> right;
probs[i] = 1.0 * (right / p - (left - 1) / p) / (right - left + 1);
}

double ret = 0;
for (int i = 0; i < n; ++i) {
auto next = (i + 1) % n;
ret += probs[i] + probs[next] - probs[i] * probs[next];
}

std::cout << std::fixed << std::setprecision(10) << ret * 2000 << '\n';

return 0;
}

0 comments on commit ac8c20e

Please sign in to comment.