The 15th Jilin Provincial Collegiate Programming Contest 总结

本文总结了在Codeforces平台上举行的吉林省第十五届大学生程序设计竞赛,包括A到M共13道题目。涉及到的问题包括随机数检查、算术运算、侦探推理、矩阵修复、公园游览等。每道题目都有详细的题意、思路和解决方法,如矩阵修复通过异或运算确定丢失数据,以及在除法模拟、概率计算、括号序列等方面的算法应用。尽管题目涵盖广泛,但翻译和理解上的困难导致了一些错误和时间浪费,最终成功解出4题。
摘要由CSDN通过智能技术生成

目录

A:Random Number Checker

 B:Arithmetic Exercise

 E:Great Detective TJC

 G:Matrix Repair

 H:Visit the Park

 K:Bracket Sequence

 L:Suzuran Loves String

 M:Sequence


A:Random Number Checker

题目链接:Problem - A - Codeforces

题面:

题意:给定一个序列,如果序列中奇数的数量和偶数的数量差值不超过1就输出Good,否则就输出Not Good

思路:签到题

这题题目意思很简单,但是由于翻译对于那句 If the difference between the number of occurrences of odd and even numbers is at most one, she thinks the generator is good.的理解不是很到位,导致wa2,以及20min后出题

#include<bits/stdc++.h>
using namespace std;


int main(){
	int n;
	while(cin >> n){
		int a;
		int x = 0, y = 0;
		for(int i = 0; i < n; i++){
			cin >> a;
			if(a & 1){
				x++;
			}else{
				y++;
			}
		}
		if(abs(x - y) > 1){
			cout << "Not Good" << endl;
		}else{
			cout << "Good" << endl;
		}
	}
	return 0;
} 

 B:Arithmetic Exercise

题目链接:Problem - B - Codeforces

题目描述:

输入描述: 输出描述:

样例:

 题意:a / b保留k位小数(4舍5入)

思路:简单除法模拟题(数据有点水)

这个就是很水的除法模拟,然后我和另一个队友不确定k的作用就在等A出了后才过

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main(){
	ll a, b, k;
	while(cin >> a >> b >> k){
		string s = "";
		int ans = a / b;
		string ss = "";
		if(ans == 0){
			s += '0';
		}
		while(ans){
			ss += (ans % 10 + '0');
			ans /= 10;
		}
		reverse(ss.begin(), ss.end());
		s += ss;
		s += '.';
		int cnt = a % b;
		for(int i = 0; i < k; i++){
			cnt *= 10;
			ans = cnt / b;
			s += ans + '0';
			cnt = cnt % b;
			if(i == k - 1){
				if(cnt * 10 / b >= 5){
					bool f = 1;
					for(int i = s.length() - 1; i >= 0; i--){
						if(s[i] == '.'){
							continue;
						}
						if(f){
							s[i] ++;
							f = 0;
							if(s[i] > '9'){
								f = 1;
								s[i] = '0';
							}
						}
					}
				}
			}
		}
		cout << s << endl;
//		cout << endl;
	}
	return 0;
}

 E:Great Detective TJC

题目链接:Problem - E - Codeforces

  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值