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
  • 相关阅读:
    20189222 《网络攻防技术》第一周作业
    apue.h 运行UNIX环境高编程序
    fflush()函数
    线性链表如何选择二级指针还是一级指针
    scanf()gets()fgets()区别
    淺談Coach思考模式
    Hello World
    C语言I博客作业04
    python模块:logging
    python模块:subprocess
  • 原文地址:https://www.cnblogs.com/Vampire6/p/12909981.html
Copyright © 2011-2022 走看看