洛谷入门赛 #26(上)

洛谷入门赛 #26

B4017 [语言月赛 202408] 相识于 2016

#include<iostream>
using namespace std;
int x , y;
int main(){
	cin >> x >> y;
	cout << (x - 2016) * 12 + (y - 8 + 1) * 1 << endl;
	return 0;
}

B4018 [语言月赛 202408] 游戏与共同语言 

#include<iostream>
using namespace std;
int x1 , x2 , x3 , y1 , y2 , y3;
int main(){
	cin >> x1 >> x2 >> x3 >> y1 >> y2 >> y3;
	if(x1 > y1) cout << 'A' << endl;
	else if(x1 < y1) cout << 'B' << endl;
	else{
		if(x2 > y2) cout << 'A' << endl;
		else if(x2 < y2) cout << 'B' << endl;
		else{
			if(x3 > y3) cout << 'A' << endl;
			else if(x3 < y3) cout << 'B' << endl;
		}
	}
	return 0;
}

B4019 [语言月赛 202408] 皆与生物有缘

#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int n , sum ;
int a[201548],b[201548];
int main(){
	cin >> n;
	for(int i = 0; i < n; i ++)
		cin >> a[i];
	for(int i = 0; i < n; i ++)
		cin >> b[i];
		
	
	for(int i = 0; i < n; i ++){
		sum += (a[i] + b[i]);
	}
	
	int ans = ceil(1.0*sum / 2);
	cout << ans << endl;
	return 0;
}

B4020 [语言月赛 202408] 两座城市的 543 千米

#include <iostream>
#include <vector>
using namespace std;

// 定义一个结构体来存储高铁信息
struct Train {
	int length; // 高铁经过的城市数量
	vector<int> cities; // 高铁经过的城市列表
};

int main() {
	int N, M, a, b; // N: 城市总数, M: 高铁总数, a: 起始城市, b: 目标城市
	cin >> N >> M >> a >> b;
	
	vector<Train> trains(M); // 存储所有高铁的信息
	
	int count = 0;
	// 读取每列高铁的信息
	for (int i = 0; i < M; ++i) {
		cin >> trains[i].length;
		bool foundA = false, foundB = false;
		trains[i].cities.resize(trains[i].length);
		for (int j = 0; j < trains[i].length; ++j) {
			cin >> trains[i].cities[j];
			if (trains[i].cities[j] == a) {
				foundA = true;
			} else if (trains[i].cities[j] == b && foundA) {
				foundB = true;
			}
		}
		if (foundA && foundB) {
			++count;
		}
	}
	cout << count << endl; // 输出符合条件的高铁数量
	
	return 0;
}

B4021 [语言月赛 202408] 于抑郁中支持

#include<iostream>
using namespace std;
const int N = 102457;
int n , t , sum;
long long a[N] , b[15000];

int chose(int n){
	if(n == 1) return 10;
	if(n == 2) return 100;
	if(n == 3) return 1000;
	return 10000;
}

int main(){
	cin >> n >> t;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
		
	for(int i = 1; i <= n; i ++){
		int temp = a[i] , chu = chose(t);
		b[temp % chu] ++;
	}
	
	for(int i = 0; i <= 9999; i ++){
		if(b[i]) sum ++;
	}
	
	cout << sum << endl;
	return 0;
}

B4022 [语言月赛 202408] 蓝色的网易云

#include<iostream>
#include<algorithm>
using namespace std;
const int M = 10245;
int n , m;
int a[M];
int main(){
	cin >> n >> m;
	for(int i = 1; i <= n; i ++){
		int t;
		cin >> t;
		a[i] = t;
	}
	sort(a + 1 , a + 1 + n);
	 
	for(int i = 1; i <= n / m; i ++){
		for(int j = 1 + i - 1; j <= n; j += (n/m)){
			cout << j << endl;
		}
	}
	return 0;
}

看到这里请点个赞吧,谢谢。

下集更精彩!!!

下集链接:洛谷入门赛 #26(下)-CSDN博客

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值