2021_HUASACM_寒假周测_1 题解

我是比赛链接

A题(huas_sy):清除内奸
思路:

#include <iostream>
using namespace std;

int n, x;

int main(){
   
    cin >> n >> x;
    int y;
    for(int i = 0; i < n; i ++){
   		//	每个数只用一次,不需要开辟额外的空间存储
        cin >> y;
        if(x != y) cout << y << ' ';	//	不相等就输出
    }
    return 0;
}

B题(the_xin):棒球比赛
思路(the_xin):
比较D在是不是小于v*s或者大于vt

#include<iostream>
using namespace std;
int main(){
   
    int n,s,t,d;
    cin>>n>>s>>t>>d;
    int sd=n*s;
    int td=n*t;
    if(d<sd||d>td)puts("Yes");
    else puts("No");
    return 0;
}

帅气的咲夜~

C题(the_xin):坏了的键盘
思路1(the_xin):
从左往右遍历整个字符数组(从1开始),累计相同字符的和若其连续相同字符个数为奇数则当前字符键盘必不可能是坏的。

#include<bits/stdc++.h> 			// 万能头文件,包含绝大多数常用头文件
using namespace std;
string s;                           // C++提供的字符串变量
int cnt[30];
int main()
{
   
	cin >> s;
	int ans = 26;
	int len = 1;
	char ch = s[0];
	for(int i = 1; i < s.length(); i ++) {
   
		if(ch == s[i]) len ++;
		else {
   
			if(len % 2 == 1 && !cnt[ch - 'a']) {
   
			
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值