2 条题解

  • 1
    @ 2018-12-11 12:00:56
    /*
    
    */
    #define method_2
    #ifdef method_1
    /*
    50分算法
    逐个枚举到底每个门通过多少人 
    */
    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    #include<cmath>
    #include<set>
    #include<map>
    #include<queue>
    #include<stack>
    #include<vector>
    #include<cstring>
    #include<cstdlib>
    using namespace std;
    typedef long long ll;
    const int maxn=+5;
    const ll INF=0x3f3f3f3f3f3f3fll;
    ll n,t1,t2;
    int main() {
        ios::sync_with_stdio(false);
    //  freopen("偷拍硕哥4.in","r",stdin);
        cin>>n>>t1>>t2;
        ll T1,T2,ans=INF; 
        for(int i=1;i<=n;i++){
            T1=t1*i;
            T2=t2*(n-i);
            ans=min(ans,max(T1,T2));
        }
        cout<<ans;
        return 0;
    }
    #endif
    #ifdef method_2
    /*
    100分算法
    显然两个门的总时间越近越好
    所以设第一个门的通过人数为a人
    则第二个门的通过人数为n-a人
    第一个门的通过总时间是a*t1
    第二个门的通过总时间是(n-a)*t1
    令 a*t1=(n-a)*t1 得a=n*t2/(t1+t2)
    然后分别测试floor(a)和floor(a)+1的答案即可 
    */
    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    #include<cmath>
    #include<set>
    #include<map>
    #include<queue>
    #include<stack>
    #include<vector>
    #include<cstring>
    #include<cstdlib>
    using namespace std;
    typedef long long ll;
    const int maxn=+5;
    const ll INF=0x3f3f3f3f3f3f3f3fll;
    ll n,t1,t2;
    int main() {
        ios::sync_with_stdio(false);
    //  freopen("偷拍硕哥4.in","r",stdin);
        cin>>n>>t1>>t2;
        ll a=n*t2/(t1+t2);
        ll a1=a+1;
    //  cout<<a<<" "<<a1<<endl;
        ll T1=a*t1;
        ll T2=(n-a)*t2;
        ll ans=max(T1,T2);
        T1=a1*t1;
        T2=(n-a1)*t2;
        ans=min(ans,max(T1,T2));
        cout<<ans;
        return 0;
    }
    #endif
    #ifdef method_3
    /*
    
    */
    
    #endif
    
    
  • 0
    @ 2022-08-02 14:39:27

    分身?谁说出题人智障的,怎么看都不对劲吧

  • 1

信息

难度
6
分类
(无)
标签
(无)
递交数
158
已通过
42
通过率
27%
被复制
6
上传者