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\n",b);
        else
        {
            ll sum=b;
            if(c<d)
                printf("-1\n");
            else{
            a=a-sum;
                if(c==d)
                    printf("-1\n");
                else{
            ll aa=(a/(c-d));
            if(a%(c-d)!=0)
                aa++;
             res=b+aa*c;
                  printf("%lld\n",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\n");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\n",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\n",d);
    }
    return 0;
}
 
View Code

 

posted @ 2020-05-18 14:38  branna  阅读(147)  评论(0编辑  收藏  举报