省赛选拔第二场

H - 水题

Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Submit

 Status Practice FZU 2182

Description

胖哥自从当上公务员,赢取白富美,走向人生巅峰后,已经懒散到不想出题了,不仅如此,他连题目都懒得看了,现在他只会根据题目第一个单词的长度判定这个题目的难度

如果题目的第一个单词太长(长度大于3),他会说这题太难,不可能想的出来; 如果题目的第一个单词太短(长度不大于3),他会说这题太简单,懒得去想

现在给定一个题目,L想知道胖哥对于这道题会作出什么反应

Input

首先是一个正整数cas,表示有cas组输入,cas<=100

对于每组输入,会给出一行,每行表示一个题目,每个题目只会由大写字母,小写字母或者空格构成,每行的第一个字符一定不会是空格,多个空格可能连续出现,每行最多200个字符

Output

对于每个题目,如果胖哥觉得这题太难,输出"Too hard!",否则输出"Too easy!"

Sample Input

12 If the day is done If birds sing no more If the wind has fiagged tired Then draw the veil of darkness thick upon me Even as thou hast wrapt the earth with The coverlet of sleep and tenderly closed The petals of the drooping lotus at dusk From the travere Whose sack of provisions is empty before the voyage is ended Whose garment is torn and dustladen Whose strength is exhausted remove shame and poverty And renew his life like a flower under The cover of thy kindly night

Sample Output

Too easy! Too easy! Too easy! Too hard! Too hard! Too easy! Too hard! Too hard! Too hard! Too hard! Too easy! Too easy!

题目意思很简单 就是处理的时候注意getchar就行

​#include<iostream>

#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

char s[100000];

int main()

{

    int t;

    scanf("%d",&t);

    getchar();

    while(t--)

    {

        getchar();

        gets(s);

        int len=strlen(s);

        int cnt=1;

        for(int i=0;i<len;i++)

        {

            if(s[i]>='A'&&s[i]<='Z'||s[i]>='a'&&s[i]<='z')

            {

               cnt++;

            }

            else

                break;

        }

//        cout<<cnt<<"**"<<endl;

        if(cnt>3)

            printf("Too hard!\n");

        else

            printf("Too easy!\n");

    }

}

I - Pangram

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit

 Status Practice CodeForces 520A

Description

A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.

You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.

Input

The first line contains a single integer n (1 ≤ n ≤ 100) — the number of characters in the string.

The second line contains the string. The string consists only of uppercase and lowercase Latin letters.

Output

Output "YES", if the string is a pangram and "NO" otherwise.

Sample Input

Input

12toosmallword

Output

NO

Input

35TheQuickBrownFoxJumpsOverTheLazyDog

Output

YES

也是水题

题意是一个句子中是否出现了26个字母 大小写一样

#include<iostream>

#include<stdio.h>

#include<algorithm>

#include<string.h>

int a[27];

char s[105];

int main()

{

    int n;

    while(~scanf("%d",&n))

    {

        memset(a,0,sizeof(a));

        scanf("%s",s);

        for(int i=0;i<n;i++)

        {

            if(s[i]>='a'&s[i]<='z')

            a[s[i]-'a']++;

            else if(s[i]>='A'&&s[i]<='Z')

            a[s[i]-'A']++;

        }

        int f=1;

        for(int i=0;i<26;i++)

        if(!a[i])

        {

            f=0;

            break;

        }

        if(f)

        printf("YES\n");

        else

        printf("NO\n");

    }

}

​J - Two Buttons

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit

 Status Practice CodeForces 520B

Description

Vasya has found a strange device. On the front panel of a device there are: a red button, a blue button and a display showing some positive integer. After clicking the red button, device multiplies the displayed number by two. After clicking the blue button, device subtracts one from the number on the display. If at some point the number stops being positive, the device breaks down. The display can show arbitrarily large numbers. Initially, the display shows number n.

Bob wants to get number m on the display. What minimum number of clicks he has to make in order to achieve this result?

Input

The first and the only line of the input contains two distinct integers n and m (1 ≤ n, m ≤ 104), separated by a space .

Output

Print a single number — the minimum number of times one needs to push the button required to get the number m out of number n.

Sample Input

Input

4 6

Output

2

Input

10 1

Output

9

Hint

In the first example you need to push the blue button once, and then push the red button once.

In the second example, doubling the number is unnecessary, so we need to push the blue button nine times.

题意:

这是我做出的第三题 想复杂了  写了一个半小时 估计正好是昨天写了一天的spfa慢脑子就spfa

当我做出来的时候发现 一堆人都ac了T T

小妹直接用数学给过了 哭T T

有一个装置 有两个按钮 

red *2 blue -1

问最少几步能把n变成m

思路 把点变成图 red就是 (i,i*2) 这条边 blue 就是 (i,i-1)

用最短路spfa 直接暴力搜​​

#include<iostream>

#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<queue>

using namespace std;

const int M=2e4+20;

const int INF=0x3f3f3f3f;

struct Edge

{

    int to,next;

}e[M<<4];

int d[M],vis[M],head[M] ;

int n,m;

int cnt=0;

void addEdge(int u,int v)

{

    e[cnt].to=v;

    e[cnt].next=head[u];

    head[u]=cnt++;

}

int Spfa()

{

    memset(d,INF,sizeof(d));

    memset(vis,0,sizeof(vis));

    d[n]=0;

    queue<int>tp;

    tp.push(n);

    vis[n]=1;

    while(!tp.empty())

    {

        int top=tp.front();tp.pop();

        for(int i=head[top];i!=-1;i=e[i].next)

        {

            int v=e[i].to;

            if(d[v]>d[top]+1)

            {

                d[v]=d[top]+1;

                if(!vis[v])

                {

                    vis[v]=1;

                    tp.push(v);

                }

            }

        }

    }

}

int main()

{

        scanf("%d%d",&n,&m);

        if(n>m)

        {

           printf("%d",n-m);

        }

        else{

                memset(head,-1,sizeof(head));

        for(int i=1;i<=10000;i++)

        {

            if(2*i<M) addEdge(i,2*i);

            if(i-1>=0) addEdge(i,i-1);

        }

        Spfa();

        printf("%d\n",d[m]);

        }

}

数学方法 算法弱爆:

#include<iostream>

#include<stdio.h>

#include<string.h>

#include<algorithm>

#include<math.h>

using namespace std;

int main()

{

    int n,m;

    scanf("%d%d",&n,&m);

    int cnt=0;

    if(n>m)

    {

        printf("%d\n",n-m);

    }

    else

    {

        while(n!=m)

        {

            if(m&1)

            {

                m+=1;

                cnt++;

            }

            m/=2;

            cnt++;

            if(n>m)

            {

                cnt=cnt+n-m;

                break;

            }

        }

        printf("%d\n",cnt);

    }

}

​C - ytaaa

Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u

Submit

 Status Practice FZU 2177

Description

Ytaaa作为一名特工执行了无数困难的任务,这一次ytaaa收到命令,需要炸毁敌人的一个工厂,为此ytaaa需要制造一批炸弹以供使用。 Ytaaa使用的这种新型炸弹由若干个炸药组成,每个炸药都有它的威力值,而炸弹的威力值为组成这个炸弹的所有炸药的最大威力差的平方,即(max-min)^2,假设一个炸弹有5个炸药组成,威力分别为5 9 8 2 1,那么它的威力为(9-1)^2=64。现在在炸弹的制造流水线上已经有一行n个炸药,由于时间紧迫,ytaaa并没有时间改变它们的顺序,只能确定他们的分组。作为ytaaa的首席顾问,请你帮助ytaaa确定炸药的分组,使制造出的炸弹拥有最大的威力和。

Input

输入由多组数据组成。第一行为一个正整数n(n<=1000),第二行为n个数,第i个数a[i]为第i个炸药的威力值(0<=a[i]<=1000)。

Output

对于给定的输入,输出一行一个数,为所有炸弹的最大威力和。

Sample Input

6 5 9 8 2 1 6

Sample Output

77

题意:让后就是这一题 简单的区间dp

我一个小时之前就写出来了 最大最小值初始化弄成了一样 前前后后弄了一个小时 最后5min ac

#include<iostream>

#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

const int INF=0x3f3f3f;

int a[1005];

int dp[1005];

int main()

{

    int n;

    while(~scanf("%d",&n))

    {

        for(int i=1;i<=n;i++)

        scanf("%d", &a[i]);

        for(int i=1; i<=n; i++)

        {

            dp[i]=dp[0] = 0;

            int maxn =-INF, minn = INF;

            for(int j=i; j>=1; j--)

            {

                maxn=max(maxn, a[j]);

                minn=min(minn, a[j]);

                dp[i]=max(dp[i], dp[j-1]+(maxn-minn)*(maxn-minn));

            }

        }

        printf("%d\n",dp[n]);

    }

}

 

 

#include<iostream>

#include<stdio.h>

​#include

​<string.h>

​#include<algorithm>

​using namespace std;char s[100000];int main(){

    int t;

    scanf("%d",&t);

    getchar();

    while(t--)

    {

        getchar();

        gets(s);

        int len=strlen(s);

        int cnt=1;

        for(int i=0;i<len;i++)

        {

            if(s[i]>='A'&&s[i]<='Z'||s[i]>='a'&&s[i]<='z')

            {

               cnt++;

            }

            else

                break;

        }//        cout<<cnt<<"**"<<endl;

        if(cnt>3)

            printf("Too hard!\n");

        else

            printf("Too easy!\n");

    }}

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

#include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;char s[100000];int main(){

    int t;

    scanf("%d",&t);

    getchar();

    while(t--)

    {

        getchar();

        gets(s);

        int len=strlen(s);

        int cnt=1;

        for(int i=0;i<len;i++)

        {

            if(s[i]>='A'&&s[i]<='Z'||s[i]>='a'&&s[i]<='z')

            {

               cnt++;

            }

            else

                break;

        }//        cout<<cnt<<"**"<<endl;

        if(cnt>3)

            printf("Too hard!\n");

        else

            printf("Too easy!\n");

    }}

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

#include<iostream>#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;char s[100000];int main(){

    int t;

    scanf("%d",&t);

    getchar();

    while(t--)

    {

        getchar();

        gets(s);

        int len=strlen(s);

        int cnt=1;

        for(int i=0;i<len;i++)

        {

            if(s[i]>='A'&&s[i]<='Z'||s[i]>='a'&&s[i]<='z')

            {

               cnt++;

            }

            else

                break;

        }//        cout<<cnt<<"**"<<endl;

        if(cnt>3)

            printf("Too hard!\n");

        else

            printf("Too easy!\n");

    }}

​​

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值