2020.10.09 Rating 补题报告

A - A Blend of Springtime

题意:找给出的字符串是否包含连续的不同的且不为“.”的三个字符,

做法:emmmm就是从头读之后判断就行

代码:

//去吧马里奥!把AC公主救回来!
//        ********
//       ************
//       ####....#.
//     #..###.....##....
//     ###.......######
//        ...........
//       ##*#######
//    ####*******######
//   ...#***.****.*###....
//   ....**********##.....
//   ....****    *****....
//     ####        ####
//   ######        ######
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<map>
#include<sstream>
#include<cstring>
#include<vector>
#include<iomanip>
#include<queue>
#include<set>
#define LL long long
#define _64 __int64
const double PI = atan(1.)*4.;
using namespace std;

char a[2000];

int main(){
    cin >> a;
    int flag = 0;
    //cout << a << endl;
    //cout << sizeof(a) << endl;
    for(int i = 1;i < strlen(a)-1;i++){
        if(a[i] != a[i+1] && a[i] != a[i-1] && a[i+1] != a[i-1] && a[i] != '.' && a[i+1] != '.' && a[i-1] != '.'){
            flag = 1;
            break;

        }
    }
    if(flag == 1){
        cout << "Yes" << endl;

    }else{
        cout << "No" << endl;
    }

}

B - A Tide of Riverscape

题意:输入一串字符串,包含“0”、“1”、“.”,其中“.”可以变成0或者1,判断第i个数和i+p是否可以不同

做法:判断,如果该点是“.”,直接全部变成0,之后判断它相对的是不是1,用一个flag记录即可

代码:

//去吧马里奥!把AC公主救回来!
//        ********
//       ************
//       ####....#.
//     #..###.....##....
//     ###.......######
//        ...........
//       ##*#######
//    ####*******######
//   ...#***.****.*###....
//   ....**********##.....
//   ....****    *****....
//     ####        ####
//   ######        ######
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<map>
#include<sstream>
#include<cstring>
#include<vector>
#include<iomanip>
#include<queue>
#include<set>
#define LL long long
#define _64 __int64
const double PI = atan(1.)*4.;
using namespace std;



int main(){
    int n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    int flag = 0;
    for(int i = 0;i < n;i++){
        if(s[i] == '.'){
            s[i] = '0';
            if(i + p < n && s[i+p] == '0' || i - p >= 0 && s[i-p] == '0'){
                s[i] = '1';
            }
        }
        if(i + p < n && s[i] != s[i+p]){
            flag = 1;
        }
    }
    if(flag == 1){
        cout << s << endl;
    }else{
        cout << "No" << endl;
    }

}

D - Infinity Gauntlet

题意:一组数据有一个颜色还有一个名字,其中有对应关系,给出颜色输出名字

做法:用数组存了(其实感觉用map会简单些),再输出就行

代码:

//去吧马里奥!把AC公主救回来!
//        ********
//       ************
//       ####....#.
//     #..###.....##....
//     ###.......######
//        ...........
//       ##*#######
//    ####*******######
//   ...#***.****.*###....
//   ....**********##.....
//   ....****    *****....
//     ####        ####
//   ######        ######
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<map>
#include<sstream>
#include<cstring>
#include<vector>
#include<iomanip>
#include<queue>
#include<set>
#define LL long long
#define _64 __int64
const double PI = atan(1.)*4.;
using namespace std;

string a[10];
string b[10];
int mark[10];

int main(){
    int n;
    cin >> n;
    for(int i = 0;i <10;i++)mark[i] = 0;
    a[1] = "Power";b[1] = "purple";
    a[2] = "Time";b[2] = "green";
    a[3] = "Space";b[3] = "blue";
    a[4] = "Soul";b[4] = "orange";
    a[5] = "Reality";b[5] = "red";
    a[6] = "Mind";b[6] = "yellow";
    if(n == 0){
        for(int i=1;i < 10;i++){
            mark[i] = 0;
        }
    }else{
        for(int i = 0;i < n;i++){

            string s;
            cin >> s;
            if(s == "purple"){
                mark[1] =1;
            }else if(s == "green"){
                mark[2] = 1;
            }else if(s == "blue"){
                mark[3] = 1;
            }else if(s == "orange"){
                mark[4] = 1;
            }else if(s == "red"){
                mark[5] = 1;
            }else if(s == "yellow"){
                mark[6] = 1;
            }
        }
    }

    cout << 6-n << endl;
    //cout << mark[3] << endl;
    for(int i = 1;i < 7;i++){
        if(mark[i] ==  0){
            cout << a[i] << endl;
        }
    }
}

E - High School: Become Human

题意:都明白

做法:取对数,e的ln次方,一通乱算可以得出这个式子就等于x的y次方,可以通过比较对数的方法比较这俩数,另外由于是double类型有精度问题,也就是比较是否相等的时候得通过差多么接近0得出,这个精度得取得很小才行

代码:

//去吧马里奥!把AC公主救回来!
//        ********
//       ************
//       ####....#.
//     #..###.....##....
//     ###.......######
//        ...........
//       ##*#######
//    ####*******######
//   ...#***.****.*###....
//   ....**********##.....
//   ....****    *****....
//     ####        ####
//   ######        ######
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<map>
#include<sstream>
#include<cstring>
#include<vector>
#include<iomanip>
#include<queue>
#include<set>
#define LL long long
#define _64 __int64
const double PI = atan(1.)*4.;
using namespace std;

int main(){
    double x,y;
    cin >> x >> y ;
    double ansx,ansy;
    //LL a,b;
    //a = x/10;
    //b = y/10;
    //ansx = pow(a,b);
    //ansy = pow(b,a);
    //cout << ansx << ansy << endl;
    //ansx = log(x)/log(y);
    //ansy = log(y)/log(x);
    ansx = y*log(x);
    ansy = x*log(y);
    //if(ansx > ansy){
    //    cout << '>' << endl;
    //}else if(ansx < ansy){
    //    cout << '<' << endl;
    //}else if(fabs(ansx - ansy) < 1e-16){
//cout << '=' << endl;
    //}
    if(fabs(ansx - ansy) <= 1e-100){
        cout << '=' << endl;
    }else if(ansx - ansy < 0){
        cout << '<' << endl;
    }else{
        cout << '>' << endl;
    }
}

F - Three displays

题意:找既满足i<j<k,且满足si<sj<sk的最少的租金

做法:直接暴力,找到一个数,分别循环两边找最小值,之后把最小值加起来再算所有最小值和中的最小值就是答案

代码:

//去吧马里奥!把AC公主救回来!
//        ********
//       ************
//       ####....#.
//     #..###.....##....
//     ###.......######
//        ...........
//       ##*#######
//    ####*******######
//   ...#***.****.*###....
//   ....**********##.....
//   ....****    *****....
//     ####        ####
//   ######        ######
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<map>
#include<sstream>
#include<cstring>
#include<vector>
#include<iomanip>
#include<queue>
#include<set>
#define LL long long
#define _64 __int64
const double PI = atan(1.)*4.;
using namespace std;

struct ans{
    int s;
    LL rent;
}anss[5000];

int main(){
    int n;
    cin >> n;
    for(int i = 0;i < n;i++){
        cin >> anss[i].s;
    }
    for(int i = 0;i < n;i++){
        cin >> anss[i].rent;
    }
    int flag1 = 0;
    int flag2 = 0;
    int flag = 0;
    LL minnx = 1e18;
    for(int i = 1;i < n-1;i++){
        LL ansx = anss[i].rent;
        flag1 = 0;
        flag2 = 0;
        LL minn1 = 1e8;
        LL minn2 = 1e8;
        for(int j = 0;j < i;j++){
            if(anss[j].s < anss[i].s){
                minn1 = min(minn1,anss[j].rent);
                flag1 = 1;
            }
        }
        for(int j = i+1;j < n;j++){
            if(anss[j].s > anss[i].s){
                minn2 = min(minn2,anss[j].rent);
                flag2 = 1;
            }
        }
        if(flag1 ==1 && flag2 == 1){
            flag = 1;
            ansx += minn1;
            ansx += minn2;
            minnx = min(minnx,ansx);
        }
    }
    if(flag == 1){
        cout << minnx << endl;
    }else{
        cout << -1 << endl;
    }
}

 

posted @ 2020-10-18 16:46  CCCCrack  阅读(153)  评论(0)    收藏  举报