QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#300800 | #7962. 前缀和 | defyers# | WA | 1ms | 3796kb | C++20 | 667b | 2024-01-08 20:13:24 | 2024-01-08 20:13:24 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
using ll = long long;
using LL = long long;
void solve(int TC) {
ll n;
long double p;
ll l, r;
cin >> n >> p >> l >> r;
ll P = round(p * 1000000);
ll LP = l * P;
ll RP = r * P;
ll L = LP / 1000000 + (LP % 1000000 != 0);
ll R = RP / 1000000;
if (L < 1) L = 1;
if (R > n) R = n;
ll ans = max(0ll, R - L + 1);
cout << ans << "\n";
}
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
cout << fixed << setprecision(10);
int t = 1;
// cin >> t;
for (int i = 1; i <= t; i++) {
solve(i);
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3796kb
input:
3 0.5 1 2
output:
1
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3696kb
input:
1 0.529148 1 1
output:
0
result:
wrong answer 1st numbers differ - expected: '0.5291480', found: '0.0000000', error = '0.5291480'