• Codeforces Beta Round #107(Div2) 补题


    A. Soft Drinking

    题意:就是喝一次饮料需要消耗多个不同的东西,给定多个东西的数量,问最多能喝多少饮料。

    题解:理解题意就很简单,根据提示写方程就行。

    代码:

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
        //20 19 30
        int n,k,l,c,d,p,nl,np;
        cin>>n>>k>>l>>c>>d>>p>>nl>>np;
        int xx,yy,zz,kk;
        xx=(k*l)/nl;
        yy=c*d;
        zz=p/np;
        kk=min(xx,min(yy,zz));
    //    cout<<kk<<endl;
        cout<<kk/n<<endl;
    } 

    B. Phone Numbers

    题意:如果6个数是一样的就是taxi,按降序排列的就是pizza,其他是girl,问具有最多这些人的电话是谁。

    题解:就是模拟,注意taxi的要求,是要6个一样的数而不是3个,然后使用sort排序输出就好。

    代码:

    #include<bits/stdc++.h>
    #include<vector>
    using namespace std;
    const int maxn =1e2+7;
    vector<string>v1;
    vector<string>v2;
    vector<string>v3;
    vector<string>::iterator it;
    struct person{
        string nm;
        int g;
        int ti=0;
        int pa=0;
        int gl=0;
    }w[maxn];
    bool pdt(int x,int y,int z){
        int aa=x/10;int bb=x%10;int cc=y/10;
        int dd=y%10;int ee=z/10;int ff=z%10;
        if(aa==bb&&bb==cc&&cc==dd&&dd==ee&&ee==ff){
            return true; 
        }
        else{
            return false;
        }
    }
    bool pdp(int x,int y,int z){
        int aa=x/10;int bb=x%10;int cc=y/10;
        int dd=y%10;int ee=z/10;int ff=z%10;
        //cout<<aa<<bb<<cc<<dd<<ee<<ff<<endl; 
        if(aa>bb&&bb>cc&&cc>dd&&dd>ee&&ee>ff){
            return true;
        }
        else{
            return false;
        }
    }
    bool cmp1(person p,person q){
        if(p.ti==q.ti){
            return p.g<q.g;
        }
        return p.ti>q.ti;
    }
    bool cmp2(person p,person q){
        if(p.pa==q.pa){
            return p.g<q.g;
        }
        return p.pa>q.pa;
    }
    bool cmp3(person p,person q){
        if(p.gl==q.gl){
            return p.g<q.g;
        }
        return p.gl>q.gl;
    }
    int main(){
        int t,n;
        string name;
        cin>>t;
        for(int i=1;i<=t;i++){
            cin>>n>>name;
            w[i].nm=name;
            w[i].g=i;
            for(int j=1;j<=n;j++){
                int a,b,c;
                char d,e;
                cin>>a>>d>>b>>e>>c;
                if(pdt(a,b,c)==1){
                    w[i].ti++;
                    continue;
                }
                if(pdp(a,b,c)==1){
                    w[i].pa++;
                    continue;
                }
                  w[i].gl++;
            }//cout<<w[i].nm<<" ";
        //    cout<<w[i].ti<<" "<<w[i].pa<<" "<<w[i].gl<<endl; 
        }
        sort(w+1,w+1+t,cmp1);
        for(int i=1;i<=t;i++){
            if(w[i].ti==w[1].ti){
                v1.push_back(w[i].nm);
            }
        }
        sort(w+1,w+1+t,cmp2);
        for(int i=1;i<=t;i++){
            if(w[i].pa==w[1].pa){
                v2.push_back(w[i].nm);
            }
        }
        sort(w+1,w+1+t,cmp3);
        for(int i=1;i<=t;i++){
            if(w[i].gl==w[1].gl){
                v3.push_back(w[i].nm);
            }
        }
        cout<<"If you want to call a taxi, you should call:";
        for(it=v1.begin();it!=v1.end();it++){
            if(it==v1.begin()){
                cout<<" "<<(*it);
            }
            else{
                cout<<", "<<(*it);
            }
        }
        cout<<"."<<endl;
        cout<<"If you want to order a pizza, you should call:";
        for(it=v2.begin();it!=v2.end();it++){
            if(it==v2.begin()){
                cout<<" "<<(*it);
            }
            else{
                cout<<", "<<(*it);
            }
        }
        cout<<"."<<endl;
        cout<<"If you want to go to a cafe with a wonderful girl, you should call:";
        for(it=v3.begin();it!=v3.end();it++){
            if(it==v3.begin()){
                cout<<" "<<(*it);
            }
            else{
                cout<<", "<<(*it);
            }
        }
        cout<<"."<<endl;
    }

    C. Win or Freeze

    题意:根据给定的数进行博弈,一直交换成非平凡因素直到不能交换为止

    题解:可以根据题目发现如果由两个素数组成就是必败的,所以我们对n做唯一性分解这个题就做完了。

    代码:

    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #define INF  1e5
    using namespace std;
    typedef long long LL;
    const int maxn = 1000 + 100;
    LL q = 0;
    int solve(LL p){
        if(p == 1){
            return 0;
        }
        LL x = p,temp = 1;
        int num = 0;
        for(LL i = 2;i * i <= p;++i){
            while(x % i == 0){
                ++num;
                if(num <= 2){
                    temp *= i;
                    x /= i;
                }else{
                    break;
                }
            }
            if(num > 2){
                break;
            }
        }
        if(x > 1){
            ++num;
        }
        if(num == 1){ 
            return 0;
        }else if(num == 2){
            return -1;
        }else{
            return temp;
        }
    
    }
    int main(){
        cin >> q;
        LL ans = solve(q);
        if(ans == -1){
            cout << "2" << endl;
        }else{
            cout << "1
    " << ans << endl;
        }
        return 0;
    } 
  • 相关阅读:
    bzoj1015: [JSOI2008]星球大战starwar 并查集+离线处理
    bzoj1051: [HAOI2006]受欢迎的牛
    bzoj1798: [Ahoi2009]Seq 维护序列seq 线段树
    codevs1163访问艺术馆 树形dp
    国标GB28181协议视频人脸识别/车牌识别平台EasyCVR国标设备接入新增录像功能开发
    海康SDK/大华SDK安防视频智能分析平台EasyCVR接入过多通道卡顿问题解决
    网络穿透设备EasyNTS上云网关如何结合智慧工地上云平台实现视频监控的多终端观看?
    TSINGSEE青犀视频EasyCVR视频融合共享平台浏览器直播页面报错无法播放如何排查?
    【解决方案】视频智能分析平台EasyCVR是如何搭建一套完善稳定的月子会所在线视频系统的?
    RTP协议可以用于直播吗?TSINGSEE青犀视频编译RTP推流程序报错类型不匹配问题解决
  • 原文地址:https://www.cnblogs.com/liyongqi/p/14801982.html
Copyright © 2020-2023  润新知