2018年第四阶段组队训练赛第九场

题目很水 不多贴了

问题 D: Team Name

时间限制: 1 Sec  内存限制: 128 MB
提交: 48  解决: 29
[提交] [状态] [讨论版] [命题人:admin]

题目描述

After all the teams have been matched, what to do next is of course to think about a nice team name. Now it is known that there are n teams taking part in the Guangxi Province Collegiate Programming Contest. And the name of every team is a string consists of English lower characters. Now Luras needs to get her team name, she doesn’t want the name be any consecutive substring of any other teams. And she prefers shorter names. If there are many choices with the shortest length, she would prefer the one which is the smallest lexicographically. Now could you decide the team name for her?  We regard string a is lexicographically smaller than string b if there exists such index j that a[i] == b[i] for all i < j and a[j] < b[j].

输入

The first line is an integer T which indicates the case number.
And as for each case, there will be n + 1 lines.
In the first line, there is one integer n, which indicates the number of teams.
Then there will be n strings of the next n lines, indicate the name of every team in each line.
It is guaranteed that—— 
T is about 100.
for 100% cases, 1 <= n <= 100, 1 <= |s|(the length of s)<= 30.

输出

As for each case, you need to output a single line.
There should be one string in the line which means the name Luras will give to her team.
 

样例输入

2
3
a
b
c
2
abcdefghijklmnopqrstuvwxyz
aa

样例输出

d
ac

#include <bits/stdc++.h>

using namespace std;

int n;
char a[105][35];
char ans[105];
bool flag;
void dfs(int dep,int len)
{
    if(len==dep)
    {
        ans[len++] = '';
        for(int i=0;i<n;i++)
            if(strstr(a[i],ans)) return;
        flag = 1;
        return;
    }
    for(int i=0;i<26;i++)
    {
        ans[dep] = i+'a';
        dfs(dep+1,len);
        if(flag) return;
    }
}
int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        cin>>n;
        for(int i=0;i<n;i++)
        {
            scanf("%s",a[i]);
        }
        flag = 0;
        int len = 1;
        while(!flag)
        {
            dfs(0,len);
            len++;
        }
        printf("%s
",ans);
    }
    return 0;
}

I: Rank LED

题目描述

The host has released the rank. Everyone’s rank is shown in the LED screen as our Picture. 
 
You could see the light line of number for ‘0’ to ‘9’ is {6、2、5、5、4、5、6、3、7、6} in the order. Luras would like to modify the position of every light line to make her new rank as small as possible while the new rank is also a positive integer without any leading zeros. What’s more, the total number of light lines should be as same as the beginning. Could you tell Luras what the best result she could modify to?
 

输入

The first line is an integer T which indicates the case number.
And as for each case, there will be 2 lines.
There is an integer n in the first line which is the length of the number string.
The 2nd line is a number string which is a non-leading zero big positive integer of length n.
It is guaranteed that——
T is about 100.
for 100% cases, 1 <= n <= 100. strings are all non-leading zero number strings.

输出

As for each case, you need to output a single line.
There should be one non-leading zero positive number string in the line which means the best rank Luras could modify to.

样例输入

3
1
9
2
99
5
10000

样例输出

6
28
2888

#include <bits/stdc++.h>

using namespace std;

int a[10]={6,2,5,5,4,5,6,3,7,6};

int main()
{
    int T;
    cin>>T;
    while(T--)
    {
        int n;
        cin>>n;
        char s[105];
        scanf("%s",s);
        int cnt = 0;
        for(int i=0;i<n;i++)
        {
            cnt+=a[s[i]-'0'];
        }
        int num7 = 0;
        while(cnt>=14)
        {
            num7++;
            cnt-=7;
        }
        string ans;
        if(cnt==2)
            ans += "1";
        else if(cnt==3)
            ans+="7";
        else if(cnt==4)
            ans+="4";
        else if(cnt==5)
            ans+="2";
        else if(cnt==6)
            ans+="6";
        else if(cnt==7)
            ans+="8";
        else if(cnt==8)
            ans+="10";
        else if(cnt==9)
            ans+="18";
        else if(cnt==10)
            ans+="22";
        else if(cnt==11)
            ans+="20";
        else if(cnt==12)
            ans+="28";
        else if(cnt==13)
            ans+="68";
        for(int i=0;i<num7;i++)
        {
            ans+="8";
        }
        cout<<ans<<endl;
    }
}

(因之后补的题 不能交 不确定AC)

原文地址:https://www.cnblogs.com/hao-tian/p/9569373.html