QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#516360 | #8795. Mysterious Sequence | SocialPanda | WA | 0ms | 3972kb | C++23 | 1.4kb | 2024-08-12 16:25:07 | 2024-08-12 16:25:07 |
Judging History
answer
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#define int long long
//#define LL long long
#define double long double
//#define lf Lf
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define PII pair<int,int>
#define Gheap priority_queue<int,vector<int>,greater<int>>
#define Lheap priority_queue<int>
#define MAXN 0x3f3f3f3f
#define MINN -0x3f3f3f3f
using namespace std;
//const int N=1e6+100,M=2*N;
//int e[N],w[M],h[M],ne[M],idx;
double aa,bb,bg,ed;
double eps = 1e-12;
int n;
bool check(double num)
{
double preB=bg;
double preA=num;
for(int i=3;i<=n;i++)
{
double newone = preA*aa+preB*bb;
preB=preA;
preA=newone;
}
if(preA-ed>eps) return false;
else return true;
}
void solve()
{
unordered_map<char,double> mp;
cin>>aa>>bb>>n>>bg>>ed;
double ll=-10.0,rr=10.0;
while(rr-ll>eps)
{
double mid = (ll+rr)/2.0;
if(check(mid)) ll=mid;
else rr=mid;
}
printf("%.9Lf\n",bg);
printf("%.9Lf\n",ll);
double preB=bg;
double preA=ll;
for(int i=3;i<n;i++)
{
double newone = preA*aa+preB*bb;
preB=preA;
preA=newone;
printf("%.9Lf\n",newone);
}
printf("%.9Lf\n",ed);
}
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt=1;
//cin >> tt;
while(tt--) solve();
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3972kb
input:
1.0 1.0 10 1 10
output:
1.000000000 -0.323529412 0.676470588 0.352941176 1.029411765 1.382352941 2.411764706 3.794117647 6.205882353 10.000000000
result:
ok 10 numbers
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3912kb
input:
1 1 2 1 100
output:
1.000000000 10.000000000 100.000000000
result:
wrong answer 2nd numbers differ - expected: '100.0000000', found: '10.0000000', error = '0.9000000'