Attack

Problem Description

PBH 最近在玩一个游戏。游戏中玩家有 100 的血量,目前有 n 个小怪,小怪会按顺序前来攻击玩家且小怪只会采用 1v1 的方式,玩家每次可秒杀一个小怪,并受到小怪攻击力的伤害(血量减少小怪攻击力的数值),打死小怪会掉落药水。

现在问题来了,打完这 n 个小怪最少需要喝多少瓶药水(喝药水不耗时)?

Input

先输入一个整数 t 表示数据的组数,t 不超过 1000。

对于每组数据,第一行先输入小怪的个数 n (1 <= n <= 100),接下来的 n 行输入小怪攻击力 atki (1 <= atki <= 50) 以及小怪掉落 mi (0 <= mi <= 4) 个药水和药水所能恢复生命的值 ai (1 <= ai <= 30)。

Output

对于每组数据先输出 "Case #x: ",x 表示当前为第几组数据,之后输出打完所有小怪需要的最少药水数。如果无法杀死这 n 个小怪,即某次攻击小怪时已无药水可用且当前血量无法攻击小怪(小怪攻击大于等于当前血量),则输出 ”QAQ”。

所有输出均不包括引号。

Example Input
3
2
50 1 20
49 0
4
50 1 10
40 0
30 3 20 30 20
10 0
3
50 3 20 15 1
45 2 1 1
27 0
Example Output
Case #1: 0
Case #2: QAQ
Case #3: 2

贪心  药瓶捡到装进背包中 , 不用 , 等到血不够再补
然后 每个药瓶精力值的处理输入
精力值有小到大排序 每次从最后取精力值
代码如下
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node
{
    int at;
    int mi;
    int a[5];
}s[110];
void sort(int top,int water[])
{
    int i , j ,t;
    for(i = 0;i<top-1;i++)
    {
        for(j = 0;j<top-i-1;j++)
        {
            if(water[j]>water[j+1])
            {
                t = water[j];
                water[j] = water[j+1];
                water[j+1] = t;
            }
        }
    }
}
int main()
{
    int t ,cas = 1,n ,i ,j ,num,top,hp,water[110],flag;
    scanf("%d",&t);
    while(t--)
    {
        memset(water,0,sizeof(water));
        scanf("%d",&n);
        for(i = 1;i<=n;i++)
        {
            scanf("%d %d",&s[i].at,&s[i].mi);
            for(j= 1;j<=s[i].mi;j++)
            {
                scanf("%d",&s[i].a[j]);
            }
        }
        num = 0;
        hp = 100;
        top = 0;
        flag = 0;
        for(i = 1;i<=n;i++)
        {
            while(hp<=s[i].at&&top!=0)
            {
                hp+=water[top-1];
                top--;
                num++;
            }
            if(hp<=s[i].at)
              {
                  flag = 1;
                  break;
              }
                hp-=s[i].at;
                for(j = 1;j<=s[i].mi;j++)
                {
                    water[top] = s[i].a[j];
                    top++;
                }
                sort(top,water);
        }
        printf("Case #%d: ",cas++);
        if(flag)
            printf("QAQ\n");
        else printf("%d\n",num);
    }
    return 0;
}
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node
{
    int at;
    int mi;
    int a[5];
}s[110];
void sort(int top,int water[])
{
    int i , j ,t;
    for(i = 0;i<top-1;i++)
    {
        for(j = 0;j<top-i-1;j++)
        {
            if(water[j]>water[j+1])
            {
                t = water[j];
                water[j] = water[j+1];
                water[j+1] = t;
            }
        }
    }
}
int main()
{
    int t ,cas = 1,n ,i ,j ,num,top,hp,water[110],flag;
    scanf("%d",&t);
    while(t--)
    {
        memset(water,0,sizeof(water));
        scanf("%d",&n);
        for(i = 1;i<=n;i++)
        {
            scanf("%d %d",&s[i].at,&s[i].mi);
            for(j= 1;j<=s[i].mi;j++)
            {
                scanf("%d",&s[i].a[j]);
            }
        }
        num = 0;
        hp = 100;
        top = 0;
        flag = 0;
        for(i = 1;i<=n;i++)
        {
            while(hp<=s[i].at&&top!=0)
            {
                hp+=water[top-1];
                top--;
                num++;
            }
            if(hp<=s[i].at)
              {
                  flag = 1;
                  break;
              }
                hp-=s[i].at;
                for(j = 1;j<=s[i].mi;j++)
                {
                    water[top] = s[i].a[j];
                    top++;
                }
                sort(top,water);
        }
        printf("Case #%d: ",cas++);
        if(flag)
            printf("QAQ\n");
        else printf("%d\n",num);
    }
    return 0;
}


### Attack Lab in Cybersecurity or Penetration Testing Attack lab is a common term used in cybersecurity and penetration testing to describe an environment where individuals can practice and develop their skills in identifying vulnerabilities, exploiting systems, and understanding the mechanics of cyberattacks. Such labs often include tools like Metasploitable[^1], which is a deliberately vulnerable operating system designed for security training and testing purposes. These environments are critical for both beginners and advanced professionals who wish to enhance their knowledge and practical abilities in ethical hacking. In the context of cybersecurity or penetration testing, an attack lab typically includes: - A controlled environment where users can simulate real-world attacks without causing harm to actual systems. - Tools such as Kali Linux, Nmap, Metasploit, and others that aid in vulnerability scanning, exploitation, and post-exploitation activities. - Virtual machines (VMs) like Metasploitable, which provide pre-configured vulnerable systems for practice. - Specific rules and guidelines to ensure safe and ethical use of the lab environment, such as prohibiting the use of unauthorized hardware like Rubber Ducky devices[^2]. Here is an example of setting up a simple attack lab using Metasploitable and Kali Linux: ```bash # On Kali Linux machine: Scan the network for active hosts nmap -sn 192.168.56.0/24 # Once the Metasploitable VM IP is identified, perform a detailed scan nmap -sV -p- 192.168.56.101 # Exploit a known vulnerability using Metasploit msfconsole use exploit/multi/http/tomcat_mgr_deploy set RHOSTS 192.168.56.101 set LHOST 192.168.56.1 exploit ``` The above commands demonstrate how to identify and exploit a vulnerability in a Metasploitable instance using Kali Linux tools. This setup allows learners to understand the process of discovering and exploiting weaknesses in a controlled manner. ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值