A - Chrome Tabs Gym - 101608A B - OverCode Gym - 101608B C - A message for you! Gym - 10160 【简单题 】

版权声明:转载请注明出处,谢谢。 https://blog.csdn.net/Mercury_Lc/article/details/88255388

A - Chrome Tabs

 Gym - 101608A 

&:之所以整理是因为自己傻到WA了好多次。

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main()
{
    int t;
    int k,n;
 freopen("tabs.in","r",stdin);
    scanf("%d", &t);
    while(t--)
    {
        scanf("%d %d", &n, &k);
        if(n == 1) printf("0\n"); //0 的时候没有
        else if(k == 1) printf("1\n"); // 两种端点情况
        else if(n == k) printf("1\n");
        else
        {
            printf("2\n"); // 其余
        }
    }
    return 0;
}

B - OverCode

 Gym - 101608B 

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int a[560];
int main()
{
    int t;
    int k,n;
   freopen("overcode.in","r",stdin);
    scanf("%d", &t);
    while(t--)
    {
        scanf("%d", &n);
        for(int i = 0; i < n; i ++)
        {
            scanf("%d", &a[i]);
        }
        sort(a,a+n);
        int res = 0;
        for(int i = 0; i < n;)
        {
            if(i + 5 < n) {
                if(abs(a[i] - a[i + 5]) <= 1000) {res ++;
                i += 6;}
                else i ++;
            }
            else break;
        }
        printf("%d\n",res);
    }
    return 0;
}

 

C - A message for you!

 Gym - 101608C  

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
char s[20];
int a[50];
int vis[50];
int main()
{
    int t;
    int n;
   freopen("scoreboard.in","r",stdin);
    scanf("%d", &t);
    while(t--)
    {
        scanf("%d\n", &n);
        memset(vis,0,sizeof(vis));
        scanf("%s", s);
        for(int i = 0; i < n; i ++)
        {
            vis[s[i] - 'A' + 1] ++;
        }
        int Max = -1;
        int res = 0;
        for(int i = 1; i <= 13 ; i ++)
        {
            scanf("%d", &a[i]);
            if(!vis[i]){
                if(Max < a[i]){
                    Max = a[i];
                    res = i;
                }
            }
        }
        printf("%c\n", res + 'A' - 1);
    }
    return 0;
}

 

猜你喜欢

转载自blog.csdn.net/Mercury_Lc/article/details/88255388