备战蓝桥杯1

#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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值