Codeforces 595D - Max and Bike

595D - Max and Bike

思路:开始和结束时的计时器的高度相同时(也就是关于圆竖着直径对称)时间最少。

证明:

总距离为d.

圆周长为s=2*π*r.

设len=d-floor(d/s)*s.

len=θ1*r+θ2*r+sin(θ1)*r+sin(θ2)*r.

要使sin(θ1)*r+sin(θ2)*r尽可能大,或者说θ1*r+θ2*r尽可能小

根据和差化积公式的

sin(θ1)+sin(θ2)=2*sin((θ12)/2)*cos((θ12)/2)

(θ12)越趋近与0,值越大。

所以θ12=θ

所以变量只剩下一个变量θ了,而且函数是单调的,所以二分解三角函数。

代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair 
#define pi acos(-1.0)
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define MAX(a,b,c) max(a,max(b,c)) 

const int INF=0x7f7f7f7f;
const int MOD=1e9+7;
const double eps=1e-6;

int main()
{
    /*ios::sync_with_stdio(false);
    cin.tie(0);*/
    int n,r,v;
    scanf("%d%d%d",&n,&r,&v);
    double s=pi*r*2;
    while(n--)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        double d=b-a;
        int c=(d/s);
        double len=d-c*s;
        double L=0,R=len;
        double mid=(L+R)/2;
        while(R-L>=eps)
        {
            if(mid+2*r*sin(mid/2/r)>=len)R=mid;
            else L=mid;
            mid=(L+R)/2;
        }
        printf("%.12lf\n",(c*s+mid)/v);
    }
    return 0;
} 

 

转载于:https://www.cnblogs.com/widsom/p/7419146.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值