郑州轻工业大学22级天梯赛

目录

1-1 无所谓,我会出手

1-2 数组总和

1-3 捡到一个矩形

1-4 字符转换

1-5 捡到了一个成绩

1-6 炎爆

1-7 攻略迷宫 

 1-8 Vampire Survivors

2-1 聚餐

2-2 捡到两个字符串

2-3 打印菱形 (Hard-ver)

2-4 弹弹珠 (Hard-ver)

3-1 最优选择

3-2 QR Code

3-3 Roll Math


1-1 无所谓,我会出手

请直接输出 :“It doesn't matter,I'll do it.”(输出不含引号)。

#include<stdio.h>
int main()
{
	printf("It doesn't matter,I'll do it.");
	return 0;
}

1-2 数组总和

#include<iostream>
using namespace std;
typedef long long LL; 
LL a[100000000];
int main() {
    LL sum = 0, n,x;
    cin >> n;

    for (int i = 1; i <=n; i++)
    {
        cin >> x;
        a[i] = x;
    }
    for (int i = 1; i <= n; i++)
    {
        sum += i * a[i];
    }
    cout << sum;
    return 0;
}

1-3 捡到一个矩形

#include<stdio.h>
int main()
{
	int x1,y1,x2,y2,a,b;
	int t,i,j=0;
	scanf("%d",&t);
	int arr[1000];
	for(i=0;i<t;i++)
	{
		scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
		scanf("%d %d",&a,&b);
		if((a>=x1&&a<=x2)&&(b>=y1&&b<=y2))
		{
			arr[j] = 1;
		}
		else
		{
			arr[j] = 0;
		}
		j++;
	}
	for(j=0;j<t;j++)
	{
		if (arr[j]==1)
		{
		printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
}

1-4 字符转换

#include<stdio.h>
#include<string.h>
int main()
{
	char a[100000];
	gets(a);
	int k=strlen(a);
	for(int i=0;i<k;i++)
	{
		if(a[i]<=109)
		a[i]=a[i]+(a[i]-96);
		else
		a[i]=2*a[i]-122;
	}
	for(int i=0;i<k;i++)
	{
		printf("%c",a[i]);
	}
	return 0; 
}
#include<iostream>
using namespace std;
int main() {
    int a;
    string ss;
    cin >> ss;
    for (int i = 0; i < ss.size(); i++)
    {
        a = ss[i] - 'a';
        if((ss[i] + a + 1)<='z')
        printf("%c", ss[i] + a+1);
        else
         printf("%c", ss[i] + a + 1-26);
    }
    return 0;
}

1-5 捡到了一个成绩

#include <stdio.h>
int main()
{
	int i,n,a;
	double sum,avg;
	scanf("%d",&n);
	int arr[n];
	for(i=0;i<n;i++)
	{
		scanf("%d",&a);
		sum += a;
		arr[i]=a;
	}
	avg = sum/n;
	int sum2 = 0;
	for(i=0;i<n;i++)
	{
		if(arr[i]>avg)
		{
			sum2+=arr[i];
		}
	}
	printf("%.3lf\n",avg);
	printf("%d",sum2);
	return 0;
}

1-6 炎爆

#include <algorithm>
#include<iostream>
typedef long long LL; 
using namespace std;
int a[101][101], n, q;
		int main(){
			cin >> n >> q;
	for (int i = 1; i <= q; i++) {
		int x, y; cin >> x >> y;
		char op; cin >> op;
	if (op == 'U') {
		for (int j = x; j >= 1; j--) a[j][y] ++;
				}
				else if (op == 'R') {
		for (int j = y; j <= n; j++) a[x][j] ++;
				}
				else if (op == 'D') {
		for (int j = x; j <= n; j++) a[j][y] ++;
				}
				else {
		for (int j = y; j >= 1; j--) a[x][j] ++;;
	}
			}
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= n; j++) {
					cout << a[i][j];
					if (j != n) cout << ' ';
				}
				cout << endl;
            }	
            return 0;
		}

1-7 攻略迷宫 

#include <algorithm>
#include<iostream>
typedef long long LL; 
using namespace std;
int sum(int h, int m, int s)
{
	return h * 3600 + m * 60 + s;
}//全部转化为秒方便统计。
int main()
{
	int x, y;
	int h1, m1, s1, h2, m2, s2;
	scanf("%d%d%d:%d:%d%d:%d:%d", &x, &y, &h1, &m1, &s1, &h2, &m2, &s2);
	int sum1 = sum(h1, m1, s1);
	int sum2 = sum(h2, m2, s2);
	int cnt = min((sum2 - sum1) / y, x);//返回 cnt 如果生命值小 也就是被打死了,反之就是没被打死
	int  res = sum1 + cnt * y;//刚开始的时间加上攻击次数×每次时间
	printf("%d\n%02d:%02d:%02d\n", cnt, res / 3600, res % 3600 / 60, res % 60);//h,m,s
	return 0;
}

 1-8 Vampire Survivors

n = int(input())  # 获取武器的数量   
# 创建字典存储武器数量  
weapons = {}  
for _ in range(n):  
    weapon = input()  # 获取武器名称  
    if weapon in weapons:  
        weapons[weapon] += 1  # 更新武器数量  
    else:  
        weapons[weapon] = 1  # 添加新武器及数量  
  
# 获取超级武器的攻击力  
super_weapon_attacks = list(map(int, input().split()))  
  
# 计算总攻击力  
total_attack = 0
pass1 =1
while pass1 == 1:
    pass1=0
    if weapons.get('Magic_Wand') and weapons.get('Empty_Tome'):  
        total_attack += super_weapon_attacks[0]  
        weapons['Magic_Wand'] -= 1  
        weapons['Empty_Tome'] -= 1
        pass1 = 1
  
    if weapons.get('Axe') and weapons.get('Candelabrador'):  
        total_attack += super_weapon_attacks[1]  
        weapons['Axe'] -= 1  
        weapons['Candelabrador'] -= 1
        pass1 = 1

    if weapons.get('Knife') and weapons.get('Bracer'):
        total_attack += super_weapon_attacks[2]
        weapons['Knife'] -= 1  
        weapons['Bracer'] -= 1
        pass1 = 1

    if weapons.get('Cross') and weapons.get('Clover'):
        total_attack += super_weapon_attacks[3]
        weapons['Cross'] -= 1  
        weapons['Clover'] -= 1
        pass1 = 1

    if weapons.get('King_Bible') and weapons.get('Spellbinder'):
        total_attack += super_weapon_attacks[4]
        weapons['King_Bible'] -= 1  
        weapons['Spellbinder'] -= 1
        pass1 = 1

    if weapons.get('Fire_Wand') and weapons.get('Spinach'):
        total_attack += super_weapon_attacks[5]
        weapons['Fire_Wand'] -= 1  
        weapons['Spinach'] -= 1
        pass1 = 1

print(total_attack)  # 输出总攻击力

2-1 聚餐

2-2 捡到两个字符串

2-3 打印菱形 (Hard-ver)

2-4 弹弹珠 (Hard-ver)

3-1 最优选择

3-2 QR Code

3-3 Roll Math

 

有时间把后面的写了,暂更。

望关注Thanks♪(・ω・)ノ 

  • 16
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

朝朝不暮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值