zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 87 (Rated for Div. 2)

    题目链接:https://codeforces.com/contest/1354

    视频讲解链接:https://www.bilibili.com/video/BV14f4y1U7tu

    A. Alarm Clock

    //
    //  main.cpp
    //  CF
    //
    //  Created by HanJinyu on 2020/5/15.
    //  Copyright © 2020 HanJinyu. All rights reserved.
    //
    
    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <set>
    #include <map>
    #include <list>
    #include <map>
    #include <cstring>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    using namespace std;
    typedef double db;
    typedef long long ll;
    int main()
    {
    #ifdef ONLINE_JUDGE
    #else
        freopen("in.txt","r",stdin);
    #endif
        int t;
        scanf("%d",&t);
        while(t--){
            ll a,b,c,d,res=0;
            scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
            if(b>=a)
                printf("%lld
    ",b);
            else
            {
                ll sum=b;
                if(c<d)
                    printf("-1
    ");
                else{
                a=a-sum;
                    if(c==d)
                        printf("-1
    ");
                    else{
                ll aa=(a/(c-d));
                if(a%(c-d)!=0)
                    aa++;
                 res=b+aa*c;
                      printf("%lld
    ",res);
                }
                }
              
            }
        }
        return 0;
    }
    View Code

    B.Ternary String

    //
    //  main.cpp
    //  CF
    //
    //  Created by HanJinyu on 2020/5/15.
    //  Copyright © 2020 HanJinyu. All rights reserved.
    //
    
    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <set>
    #include <map>
    #include <list>
    #include <map>
    #include <cstring>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    using namespace std;
    typedef double db;
    typedef long long ll;
    int main()
    {
    #ifdef ONLINE_JUDGE
    #else
        freopen("in.txt","r",stdin);
    #endif
        int t;
        scanf("%d",&t);
        while(t--){
            string s;
            cin>>s;
            int len=s.length();
            if(len<=2||s.find("1")==-1||s.find("2")==-1||s.find("3")==-1)
            {
                printf("0
    ");continue;
            }
            int _1=0,_2=0,_3=0;
            bool flag=false,flag1=false,flag2=false;
            int res=200010;
            for(int i=0;i<len;i++)
            {
                if(s[i]=='1')
                {
                    flag=true;_1=i;
                }
                else if(s[i]=='2')
                {
                    flag1=true;_2=i;
                }
                else
                {
                    flag2=true;_3=i;
                }
                if(flag&&flag1&&flag2)
                {
                    int zz=min(_1,min(_2,_3));
                    int yy=max(_1,max(_2,_3));
                    res=min(res,yy-zz+1);
                }
            }
            printf("%d
    ",res);
            
        }
        return 0;
    }
    View Code

    C1.Simple Polygon Embedding

    //
    //  main.cpp
    //  CF
    //
    //  Created by HanJinyu on 2020/5/15.
    //  Copyright © 2020 HanJinyu. All rights reserved.
    //
    #include <stdio.h>
    #include <string.h>
    #include <iostream>
    #include <algorithm>
    #include <vector>
    #include <queue>
    #include <set>
    #include <map>
    #include <list>
    #include <map>
    #include <string>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    using namespace std;
    typedef double db;
    typedef long long ll;
    const int maxn=2e5+10;
    const double PI=acos(-1.0);
    int main()
    {
    #ifdef ONLINE_JUDGE
    #else
        freopen("in.txt","r",stdin);
    #endif
        int t;
        scanf("%d",&t);
        while(t--){
            int n;
            scanf("%d",&n);
            double co=cos((2*PI)/(4*n));
            double si=sin((2*PI)/(4*n));
            double d=(co/si);
            printf("%.9lf
    ",d);
        }
        return 0;
    }
     
    View Code
  • 相关阅读:
    JS的中数的取值范围的大小
    前端通过xlsx插件导入excel
    H5和安卓原生进行交互的操作流程记录
    javascript中字符串和数字之间互相转换的方法总结
    gitlab代码合并到主分支
    typeof和valueof、instance of 之间的区别
    javascript中map会改变原始的数组吗
    使用typescript来写react遇到的一些问题
    使用javascript进行时间数据格式的转换
    在vue的移动端项目中使用vue-echarts
  • 原文地址:https://www.cnblogs.com/Vampire6/p/12909981.html
Copyright © 2011-2022 走看看