测试题

题目传松门:传送门
A题:
  • Annie is a kawaii loli in League of LegendsHigh Councilor Kiersta Mandrake said that Annie may be one of the most powerful champions ever to have fought in a Field of Justice.

    Annie has an ability, Molten Shield(熔岩护盾). This shield increases Annie's armor and magic resist and damages enemies who hit Annie with basic attacks.

  • 输入

  • This problem contains several cases.
    The first line of each case contains two integers N and S, indicate the number of attack times and the spell power of Annie's. (0 < N ≤ 1000, 0 < s ≤ 1000)
    Then N lines followed. Each line is a decimal number that indicates the time moment of that base attack. The decimal number will not exceeds 1000.
  • 输出
  • You should output the magic damage via the Molten Shield. 1 decimal places reserved.
  • 样例输入
  • 5 301
    2.00
    5.01
    5.00
    8.00
    14.03
  • 样例输出
  • 360.6
  • 提示
  • 简单的讲一下题意:
    题意是说:安妮有一个大招,释放后持续5秒,10的冷却时间(一旦释放大招就开始冷凝(对我这不玩游戏的就是一个打击)),释放大招的
  • 过程中,可以对敌人增加魔法伤害。问最后的伤害值是多少。就拿样例解释一下吧,持续时间是5秒,2秒的这个可以造成伤害,5.00的这个
  • 也可以造成伤害。而5.01,8.00确是在冷凝的时间内,没有攻击效果。14.03这个先对10取余,然后发现是4.03也在攻击之间。所以攻击是3次
  • 然后利用给出的公式就可以计算出答案。
  • 代码::
  • int main()
    {
        int n,s;
       while(~scanf("%d%d",&n,&s))
       {
           int ans=0;
           double l;
           for(int i=0;i<n;i++)
           {
               scanf("%lf",&l);
               int l1=(int)l;
               int l2=l1%10;
               if(l2>5||(l2==5&&l-l1>0))
                continue;
               else
                ans++;
           }
           double t1=60+(0.2*(double)s);
           printf("%.1lf\n",ans*t1);
       }
    }
    

B题

Blitzcrank  is a robot. 

There are some pretty good registers(寄存器) in Blitzcrank'sbody.

There are some instructions about register A and register B:

1.ADD A, B means a += bThe machine code is 80 AF BF.

2.ADD A, A means a += aThe machine code is F0 AF.

3.ADD B, B means b += bThe machine code is F0 BF.

4.ADD B, A means b += aThe machine code is 80 BF AF.

Now give you the values in register A and register B and some machine codes. You should calculate out the final value in register A and register B after operating the machine code.

Input
The frist line contains an integer T, means there are T test cases. 
For each test case, the first line contains two integers means the initial value of the register A and the register B in hexadecimal(十六进制). 
The next line contains a series of hexadecimal numbers.
Output
For each test case, print the register A and register B's value in hexadecimal.
Sample Input
2
A1 B2
80 AF BF F0 AF
B2 B3
F0 AF F0 BF
Sample Output
2A6 B2
164 166
Hint
The first case's machine codes 80 AF BF F0 AF is composed of ADD A, B and ADD A, A.

这道题主要是考的是16进制的输入。很简单

代码:

int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        int a,b;
        char a1[1000];
        scanf("%x%x",&a,&b);
        getchar();                                 //一整串字符要用gets输入。
        gets(a1);
       // printf("%s",a1);
        int l=strlen(a1);
        //printf("%d\n",l);
        for(int i=0;i<l;i++)
        {
            if(a1[i]=='8'&&a1[i+3]=='A')
            {
                a+=b;
                i+=8;
            }
            else if(a1[i]=='8'&&a1[i+3]=='B')
            {
                b+=a;
                i+=8;
            }
            else if(a1[i]=='F'&&a1[i+3]=='A')
            {
                a+=a;
                i+=5;
            }
            else if(a1[i]=='F'&&a1[i+3]=='B')
            {
                b+=b;
                i+=5;
            }
        }
        printf("%X %X\n",a,b);
    }
}

C题:

Elise is the Spider Queen . She has a skill,Spider Form (蜘蛛形态) . 

When she transformed to the spider, there will be some small spiders around her.

But she has a problem - the small spiders will have infighting because of less common interest. So Elise decided to train their interesting.

At least, they must have common interest no matter directly or indirectly.

How to train theirs interest in least cost? We assume that train a interest for a spider cost 1 strength and there are at most 100 interests in total.

    Input

          This problem contains several cases. 

The first line of each case is an integer N (1 ≤ N ≤ 100), indicates the number of spiders. 
Then N lines followed. 
The ith line contains an integer Ti (0 ≤ Ti ≤ 100) that indicates the number of this spider's interest and Ti strings indicate the interests. You can assume there are only lowercase letters in the strings and no longer than 20.
Output
For each case, you should output the least cost.

这道题其实看懂了就不难的,就是暴力加上并查集。不过就是其中有一点小细节需要注意一下。

就是当蜘蛛的技能为零时消耗的能量需要讨论一下。而且其中的时间复杂度也是相当高的,四层for循环。

代码:

struct node
{
    int n;
    char b[100][100];
} a[100];
int pre[105];
int vis[105];
int Find(int x)
{
    int r=x;
    while(pre[r]!=r)
        r=pre[r];
    int i=x,j;
    while(i!=r)
    {
        j=pre[i];
        pre[i]=r;
        i=j;
    }
    // printf("%d\n",r);
    return r;
}
void join(int x,int y)
{
    int flag=0;
    for(int i=0; i<a[x].n; i++)
    {
        for(int j=0; j<a[y].n; j++)
        {
            if(strcmp(a[x].b[i],a[y].b[j])==0)
            {
                pre[x]=y;
                flag=1;
            }
            if(flag==1)
                break;
        }
        if(flag==1)
            break;
    }
}
int main()
{
    int T;
    while(~scanf("%d",&T))
    {
        int ans1=0;
        for(int i=0; i<105; i++)
            pre[i]=i,vis[i]=0;
        for(int i=0; i<T; i++)
        {
            scanf("%d",&a[i].n);
            for(int j=0; j<a[i].n; j++)
                scanf("%s",a[i].b[j]);
            if(a[i].n==0)
                ans1++;                                    //需要特殊讨论
        }
        if(ans1==T)
            printf("%d\n",ans1);
        else
        {


            for(int i=0; i<T; i++)
            {
                for(int j=0; j<T; j++)
                {
                    if(i!=j)
                    {
                        // printf("********\n");
                        // printf("%d  %d\n",i,j);
                        if(Find(i)==Find(j))
                        {
                            continue;
                        }
                        else
                        {
                            // printf("******\n");
                            join(i,j);


                        }
                    }
                }
            }
            int ans=0;
            for(int i=0; i<T; i++)
            {
                vis[Find(i)]=1;
            }
            for(int i=0; i<T; i++)
            {
                if(vis[i])
                {
                    ans++;
                    // printf("%d\n",i);
                }
            }
            printf("%d\n",ans-1);
        }
    }


}

D题:

There are a LCD (Liquid Crystal Display) on Ezreal 's arm. The LCD is composed of liquid crystal , and the LCD is 16 lines and 48 rows. H ow did it work?

The CPU will send a series of bytes to theLCD. A byte means to eight bits. When the LCDreceived the byte, it will show a pagevertically. And each byte will display from bottom to top.

For example, 0x01 0x9C 0xED will be shown as below:

*.*
...
.**
.**
.*.
..*
..*
.**
Now give you 64 bytes, you should print it to the  LCD  from left to right and top to bottom.  32 columns  in a  Big Row  (containing  8 rows ).

Input
First line contains an integer T (T < 100), means the test case. 
For each case, there are 2 lines which contain 64 hexadecimal numbers, and it is less than 0xff.
Output
For each test case, print the LCD's status.
Sample Input
1
01 9C ED DD 1A 2B CF CD C3 00 19 D0 5A 9F 56 13 E5 40 E5 46 E3 BD 4F A4 39 AF D8 2D 6F D4 54 36
1C B5 3C 24 9F 85 01 75 10 4B A0 00 77 44 77 7D 3B 82 57 47 DD DA DA 61 E5 FD F7 B7 1D E5 D3 A7
Sample Output
*.**.****.*..*.**.*.***.**.**...
....***.*...****...**.*..*..*..*
.***..**.....**.*.**.***.*.*****
.*******..*.**.......**.*****...
.*.**.....******.....*..*.*..***
..*..*..........*.*.**.***.**..*
..**..***..**.*.*****.*...*.***.
.***..***..*.*..*.*.**.*.**..*..
.*..****.*..*.***.***..*********
....*....*..*.*.****.**...**..**
******.*....****..***...******.*
*.*.*....*.....**...***..*..*...
***.*..**...*.***.*.***..****.*.
.***...*..*.*.***......*****.*.*
.......*.*..****..*********..**.
.*..**....*......*..***.****.***
这道题也是自己卡的时间比较久的一道题。虽然题是不难,可是就是在做题的时候出现的一点小小的问题导致自己一直在错误

不停错误。经过学长的指点还是最后将它做出来了。

优代码:



int merry[25][50];
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        memset(merry,0,sizeof(merry));
        int u;
        for(int i=0;i<32;i++)
        {
            scanf("%X",&u);
            for(int j=0;j<8;j++)
            {
                merry[j][i]=u%2;
                u=u/2;
            }
        }
        for(int i=0;i<32;i++)
        {
            scanf("%X",&u);
            for(int j=8;j<16;j++)
            {
                merry[j][i]=u%2;
                u=u/2;
            }
        }
        for(int i=0;i<16;i++)
        {
            for(int j=0;j<32;j++)
            {
                if(merry[i][j]==1)
                    printf("*");
                else
                    printf(".");
            }
            printf("\n");
        }
    }}


}

自己写的比较复杂一点的代码:





int merry[25][50];
int main()
{
    int n;
    scanf("%d",&n);
    getchar();                  //getchar()一定要放对位置,不然的话就会多吸收其他的字符。特别需要注意。
    while(n--)
    {
        memset(merry,0,sizeof(merry));
        char a[1000],a1[1000];
        gets(a);
        gets(a1);
        int l1=strlen(a);
        int z2=0;
        for(int i=0; i<l1; i++)
        {
            int t=0;
            if(a[i]>='0'&&a[i]<='9')
                t+=a[i]-'0';
            else
                t+=a[i]-'A'+10;
            if(a[i+1]>='0'&&a[i+1]<='9')
                t=t*16+a[i+1]-'0';
            else
                t=t*16+a[i+1]-'A'+10;
            for(int j=0; j<8; j++)
            {
                merry[j][z2]=t%2;
                t=t/2;
            }


            if(a1[i]>='0'&&a1[i]<='9')
                t+=a1[i]-'0';
            else
                t+=a1[i]-'A'+10;
            if(a1[i+1]>='0'&&a1[i+1]<='9')
                t=t*16+a1[i+1]-'0';
            else
                t=t*16+a1[i+1]-'A'+10;


            for(int j=8; j<16; j++)
            {
                merry[j][z2]=t%2;
                t=t/2;
            }


            z2++;
            i+=2;
        }
        for(int i=0; i<16; i++)
        {
            for(int j=0; j<z2; j++)
                if(merry[i][j]==1)
                    printf("*");
                else
                    printf(".");
            printf("\n");
        }
    }
}

G题:

Granite Shield ( 花岗岩护盾 ) Malphite is shielded by a layer of rock which absorbs damage up to 10% of his maximumHealth . 

If Malphite has not been hit for 10 seconds, this effect recharges.

To simply this problem all the calculation will in integer not decimal. For example, 15 / 10 is 1 not 1.5.

Input
There are muti-case. 
For each case, the first line contain two integer M (0 < m < 10000), N (0 < N < 10000). 
M means to the maximum health, N is the time Malphite is attacked. 
The following N lines, each line contain two integer Ti ( 0 ≤ Ti ≤ 10000), Di (0 < Di ≤ 100), stands for the attack time and the damage.
Output
For each test case, output the Malphite's final health value, if Malphite can't afford all these damage, print "I'm dead!".
Sample Input
10 2
1 3
4 5
10 2
1 3
11 5
10 1
11 11
Sample Output
3
4
I'm dead!
这道题可以说是极具认真的题。也是自己花了好长的时间才补出来的题。

下面就总结一下:

刚开始的时候认为这不就是一道简单的题吗?
其实到最后的事后发现自己错了。不够认真,不够仔细。

题意:
又是英雄联盟中的一个英雄,它的一个招式防御的招式,所以释放大招,之后可以阻挡对方的攻击,如果是10秒钟之内

不受攻击的,大盾就又会重置。

自己犯了两点的错误,

第一:当他的防御大于攻击的时候,将防御剩下的加到hp上去了。

第二:我在标记大盾重置时间点时,没有将它不断地更新时间,当时想的事,从第一次大盾重置到下一次大盾重置的之间的时间

就可以了。

代码:

int main()
{
    int m,n;
    while(~scanf("%d%d",&m,&n))
    {
       int t,a;
       int pow=m/10;
       int pow2=pow;
       int flag=0,falg2=1;
       for(int i=0;i<n;i++)
       {
            scanf("%d%d",&t,&a);
            if(t-flag>=10)
            {
                pow=pow2;
            }
            if(pow>=a)
                pow-=a;
            else
              {
                   m=m-a+pow; pow=0;
              }
           if(m<=0)
            falg2=0;
           flag=t;
       }
      if(!falg2)
        printf("I'm dead!\n");
      else
        printf("%d\n",m);
    }
}

acm这条道路真的很难走,但是坚持下去,你就会有好的收获,这条道路不知道还能走多久,但是只要还在一天就会好好的学下去。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值