备战蓝桥杯1

cpp 复制代码
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
using namespace std;
int n, k;
double arr[30][30];
double sum[30];
double sum1[30];
int n1[30];
int ave[30];
struct student
{
	double score;
	int team;
};
vector<student>v;
int round_0(double n)
{
	if (n > 0)
		return n - int(n) >= 0.5 ? int(n) + 1 : int(n);
	else
		return -n - int(-n) >= 0.5 ? -(int(-n) + 1) : -int(-n);
}

bool cmp(student stu1, student stu2)
{
	if (stu1.score == stu2.score)
	{
		return stu1.team < stu2.team;
	}
	return stu1.score > stu2.score;
}
int main()
{
	cin >> n >> k;
	student stu;
	char ch;
	double s;
	for (int i = 1;i <= n;i++)
	{
		cin >> s;
		cin >> ch;
		int c = int(ch - 64);
		stu.score = s;
		stu.team = c;
		v.push_back(stu);
	}
	for (int i = 1;i <= k;i++)
	{
		for (int j = 1;j <= k;j++)
		{
			cin >> arr[i][j];
			sum[j] += arr[i][j];
			sum1[j] += arr[i][j];
		}
	}
	for (int i = 1;i <= k;i++)
	{
		for (int j = 1;j <= k;j++)
		{
			if (abs(arr[i][j] - sum[j] / k) > 15)
			{
				n1[j]++;
				sum1[j] -= arr[i][j];
			}
		}
	}
	for (int i = 1;i <= k;i++)
	{
		ave[i] = round(sum1[i] / (k - n1[i]));
		//cout << ave[i] << " ";
	}

	for (vector<student>::iterator it = v.begin();it != v.end();it++)
	{
		int x = (*it).team;
		(*it).score = round(((*it).score * 6 + ave[x] * 4) / 10);
	}
	sort(v.begin(), v.end(), cmp);
	for (vector<student>::iterator it = v.begin();it != v.end();it++)
	{
		cout << fixed << setprecision(0) << (*it).score << ' ';
		cout << char((*it).team + 64) << endl;
	}
	return 0;
}
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
bool is[50005];
bool use[26];
int main()
{
	string str;
	cin >> str;

	int len = str.length();
	int cnt = len;

	for (int i = 0;i < str.length();i++)
	{
		
		memset(use, 0, sizeof(use));
		use[int(str[i]) - 97] = true;
		if (str[i] == str[i + 1]) {
			is[i] = 1;
			cnt += 1;
		}
		for (int j = 1;j <= str.length();j++)
		{
			if (j + i >= len || i - j < 0||str[i+j]!=str[i-j]|| use[int(str[i + j])-97]==true)break;
			cnt++;
			use[i + j] = true;
			use[i - j] = true;
			/*for (int z = i-j;z <= j + i;z++)
			{
				cout << str[z];
			}
			cout << endl;*/
		}
	}
	for (int i = 0;i < str.length();i++)
	{
		memset(use, 0, sizeof(use));
		if (is[i])
		{
			use[int(str[i]) - 97] = true;
			for (int j = 1;j <= str.length();j++)
			{
				if (j + i + 1 >= len || i - j < 0 || str[i + j + 1] != str[i - j] || use[int(str[i + j + 1]) - 97] == true)break;
				cnt++;
				use[i +1+ j] = true;
				use[i - j] = true;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}
相关推荐
愈谦卑12 分钟前
数据结构:排序
数据结构·算法·排序算法
好记性+烂笔头20 分钟前
hot100_108. 将有序数组转换为二叉搜索树
算法·leetcode·职场和发展
tt55555555555531 分钟前
每日一题——主持人调度(二)
c语言·数据结构·算法·leetcode·八股文
技术蔡蔡1 小时前
Android字节码处理-函数耗时统计揭秘
算法·面试
qing_0406031 小时前
数据结构——二叉搜索树
数据结构·c++·二叉树·二叉搜索树
Felven1 小时前
B. Skibidus and Ohio
算法
yonuyeung1 小时前
代码随想录算法【Day54】
java·数据结构·算法
Ljw...1 小时前
DeepSeek+Kimi生成高质量PPT
数据库·c++·powerpoint·ppt·deepseek
敲上瘾1 小时前
基础dp——动态规划
java·数据结构·c++·python·算法·线性回归·动态规划
西猫雷婶2 小时前
python学智能算法(三)|模拟退火算法:深层分析
算法·机器学习·模拟退火算法