精度——洛谷P1033 自由落体

    xiaoxiao2021-04-15  29

    https://www.luogu.org/problem/show?pid=1033 这个题目卡我精度5555555555555555555555555 所以一定要把题目里给你的精度误差用起来; 我用的方法是算出球落到车顶和车底的区间; 然后通过区间算答案; 理论上是O(1); 但没他们O(n)快5555555555555555555;

    #include<map> #include<cmath> #include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> using namespace std; double h,s1,v,l,k; int n; int main() { scanf("%lf%lf%lf%lf%lf%d",&h,&s1,&v,&l,&k,&n); double time_oncar=sqrt((h-k)/5); double carend=(s1+l)-v*time_oncar+0.0001; double time_under=sqrt(h/5); double start=s1-v*time_under-0.0001; int s,e,ans; s=start; if(double(s)!=start)s++; e=carend; ans=min(n-1,e)-max(0,s)+1; printf("%d",max(ans,0)); }
    转载请注明原文地址: https://ju.6miu.com/read-671765.html

    最新回复(0)