QFNU 10-09 19 Training 补题

A - A Blend of Springtime

找一个字符串中是否有连续的三个字符,这三个字符都不相等,且不为"."

#include <bits/stdc++.h>
#include<algorithm>
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define ll long long
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define eps 1e-6
using namespace std;
int main()
{
    string ch;
    cin>>ch;
    int l=ch.length();
    int flag=0;
    for(int i=0;i<l-2;i++)
    {
        if(ch[i]!=ch[i+1]&&ch[i+1]!=ch[i+2]&&ch[i+2]!=ch[i]&&ch[i]!='.'&&ch[i+1]!='.'&&ch[i+2]!='.')
            flag++;
    }
    if(flag)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

D - Infinity Gauntlet

给定N个字符串,找出没有出现的字符串,对应输出字符串

#include <bits/stdc++.h>
#include<algorithm>
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define ll long long
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define eps 1e-6
using namespace std;
const int maxn=1000;
int main()
{
    int i,n;
    string str;
    string a[10]={"purple", "green", "blue", "orange", "red", "yellow"};
    string b[10]={ "Power", "Time", "Space", "Soul", "Reality", "Mind" };
    cin>>n;
    cout<<6-n<<endl;
    while(n--){
        cin>>str;
        for(i=0;i<6;i++){
            if(str==a[i]){
                a[i][0]='-';
                break;
            }
        }
    }
    
    for(i=0;i<6;i++){
        if(a[i][0]!='-'){
            cout<<b[i]<<endl;
        }
    }
    return 0;
}

B - A Tide of Riverscape

给定一个字符串,由‘0’,‘1’,‘.’;   '.'可转换成1或0,能否让这个字符串的循环周期为p,能的话输出填满之后的01串,不能的话输出No

#include<bits/stdc++.h>
using namespace std;
char str[2010];
int main()
{
    int n, p;
    cin >> n >> p >> str;
    bool flag = 0;
    for (int l = 0, r; (r = l + p) < n; l++)
    {
        if (str[l] != str[r])
        {
            if (str[l] == '.')
                str[l] = ('1' - str[r]) + '0';
            else if (str[r] == '.')
                str[r] = ('1' - str[l]) + '0';
            flag = true;
            break;
        }
        else if (str[l] == '.')
        {
            str[l] = '1', str[r] = '0';
            flag = true;
            break;
        }
    }
    if (flag)
    {
        for (int i = 0; i < n; i++)
        {
            if (str[i] == '.')
                cout<<0;
            else
                cout<<str[i];
        }
        cout<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}

E - High School: Become Human

比较x^y 与 y^x 那个大

#include<bits/stdc++.h>
using namespace std;
char str[2010];
int main() {
    long long a,b;
    cin>>a>>b;
    long double x=b*log(a);
    long double y=a*log(b);
    if(x>y)
        cout<<">"<<endl;
     else if(x==y)
        cout<<"="<<endl;
     else cout<<"<"<<endl;
    return 0;
}

 

posted @ 2020-10-18 21:13  一只幽灵飘过  阅读(49)  评论(0编辑  收藏  举报