QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#506430 | #6423. Fireworks | Railgun2334 | WA | 1ms | 4056kb | C++20 | 3.3kb | 2024-08-05 17:24:10 | 2024-08-05 17:24:10 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define re read()
#define MOD 998244353
#define i128 __int128
#define pll pair<ll,ll>
#define pii pair<int,int>
#define ull unsigned long long
#define INF 9223372036854775800
#define fr(i, x, y) for (int i = x, p = y; i <= p; ++i)
#define rp(i, x, y) for (int i = x, p = y; i >= p; --i)
#define Timeok ((double)clock() / CLOCKS_PER_SEC < MAX_TIME)
const double MAX_TIME = 1.0 - 0.0032;
inline ll read() {
ll x = 0, f = 0;
char ch = getchar();
while (!isdigit(ch))
f |= (ch == '-'), ch = getchar();
while (isdigit(ch))
x = (x << 1) + (x << 3) + (ch ^= 48), ch = getchar();
return f ? -x : x;
}
void write(i128 x) {
if (x < 0)
putchar('-'), x = -x;
if (x > 9)
write(x / 10);
putchar(x % 10 + 48);
}
inline void W(i128 x, char ch) {
write(x);
putchar(ch);
}
ll ksm(ll a, ll b, ll mod) { //快速幂mod
a %= mod;
ll res = 1;
while (b > 0)
{
if (b & 1)
res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
ll ksm(ll a, ll b) { //快速幂
ll res = 1;
while (b > 0)
{
if (b & 1)res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
pii fib(ll n) { //计算第n和n+1位斐波那契数
if (n == 0)return{ 0,1 };
auto p = fib(n >> 1);
ll c = p.first * (2 * p.second - p.first);
ll d = p.first * p.first + p.second * p.second;
if (n & 1)
return { d,c + d };
else
return { c,d };
}
ll exgcd(ll a, ll b, ll& x, ll& y) { //扩展欧几里得
ll x1 = 1, x2 = 0, x3 = 0, x4 = 1;
while (b != 0) {
ll c = a / b;
std::tie(x1, x2, x3, x4, a, b) =
std::make_tuple(x3, x4, x1 - x3 * c, x2 - x4 * c, b, a - b * c);
}
x = x1, y = x2;
return a;
}
bool liEu(ll a, ll b, ll c, ll& x, ll& y) { //线性同余方程
ll d = exgcd(a, b, x, y);
if (c % d != 0) return 0;
ll k = c / d;
x *= k;
y *= k;
return 1;
}
ll r[105]; //取模数
ll CRT(int k, ll* a, ll* r) { //中国剩余定理
ll n = 1, ans = 0;
for (int i = 1; i <= k; i++) n = n * r[i];
for (int i = 1; i <= k; i++) {
ll m = n / r[i], b, y;
exgcd(m, r[i], b, y); // b * m mod r[i] = 1
ans = (ans + a[i] * m * b % n) % n;
}
return (ans % n + n) % n;
}
/*
ll Lucas(ll n, ll m, ll p) {
if (m == 0) return 1;
return (C(n % p, m % p, p) * Lucas(n / p, m / p, p)) % p;
}
*/
int gcd(int a, int b) {
return b == 0 ? a : gcd(b, a % b);
}
int lcm(int a, int b) {
return a * b / gcd(a, b);
}
/*------------C-O-D-E------------*/
const int N = 1e5 + 4;
//int n, m, M, mod=998244353;
long double pi[10005];
long double t1,t2,p;
long double check(long double i)
{
return (t1*i+t2)/(1.0-pow(p,i));
}
void solve()
{
std::cin>>t1>>t2>>p;
if(p==10000)
{
printf("%.12Lf\n",t1+t2);
return;
}
p=1.0-p*0.0001;
//long double pp=1.0-p*0.0001;
/*
pi[0]=1;
for(int i=1;i<=10000;i++)
{
pi[i]=pi[i-1]*pp;
}
for(int i=1;i<=10000;i++)
{
long double sum=(t1*i+t2)/(1.0-pi[i]);
}
*/
int l=1,r=1e9;
long double mid;
long double lmid,rmid;
while(r-l>1)
{
mid=(l+r)/2;
lmid=mid-1e-6;
rmid=mid+1e-6;
if(check(rmid)>check(lmid))
{
r=mid;
}
else
{
l=mid;
}
}
printf("%.12Lf\n",check(l));
}
int main()
{
ios::sync_with_stdio(false);
std::cin.tie(0);std::cout.tie(0);
ll T = 1;
std::cin>>T;
while (T--)
{
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3960kb
input:
3 1 1 5000 1 1 1 1 2 10000
output:
4.000000000000 10141.585289113577 3.000000000000
result:
ok 3 numbers
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 4056kb
input:
20 10 27 2855 79 59 6888 65 72 7725 78 50 2888 31 21 5759 41 58 6619 47 27 3881 35 55 5095 77 7 6028 17 89 1792 84 60 8604 58 44 4923 88 27 3824 54 63 1482 19 42 5366 93 76 97 100 99 8660 96 36 4343 90 56 9515 24 44 9922
output:
89.729805650548 200.348432055749 177.346278317152 443.213296398892 90.293453724605 149.569421362744 190.672507085803 176.643768400393 139.349701393497 277.313756442924 167.364016736402 207.190737355271 300.732217573222 589.058848950519 113.678717853149 10798.418669628464 229.792147806005 303.9373704...
result:
wrong answer 4th numbers differ - expected: '416.83988', found: '443.21330', error = '0.06327'