栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

“思特奇杯”编程之星初赛

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

“思特奇杯”编程之星初赛

A:门牌制作
#include 
using namespace std;
int main(){
	cout << 624 << endl;
	return 0;
}

B:既约分数
#include 
using namespace std;
int main(){
	cout << 2481215 << endl;
	return 0;
}

C:蛇形填数
#include 
using namespace std;
int main(){
	cout << 761;
	return 0;
}

D:跑步锻炼
#include 
using namespace std;
int main(){
	cout << 8879;
	return 0;
}

E:七段码
#include 
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0);
const int N = 10;
int ans, a[N];
bool e[N][N], use[N];
void init(){
	//e[i][j] = 1表示i,j相邻
	e[1][2] = e[1][6] = true;
	e[2][1] = e[2][7] = e[2][3] = true;
	e[3][2] = e[3][4] = e[3][7] = true;
	e[4][3] = e[4][5] = true;
	e[5][4] = e[5][6] = e[5][7] = true;
	e[6][1] = e[6][5] = e[6][7] = true;
}
int find(int u){//并查集 
	if(a[u] == u)
		return u;
	return a[u] = find(a[u]);
}
void join(int x, int y){
	int fx = find(x), fy = find(y);
	if(fx != fy)
		a[fx] = fy;
}
void dfs(int d){
	if(d > 7){//dfs边界 
		//初始化 
		for(int i=1;i<=7;i++)
			a[i] = i;
		for(int i=1;i<=7;i++)//遍历 
			for(int j=1;j<=7;j++)
				if(e[i][j] && use[i] && use[j])
					join(i, j);
		int k = 0;
		for(int i=1;i<=7;i++)
			if(use[i] && a[i] == i)
				k++;
		if(k == 1)
			ans++;
		return;
	}
	use[d] = true;//打开序号为d的灯
	dfs(d + 1);//开下一个灯 
	use[d] = false;//关闭
	dfs(d + 1); 
}
int main(){
	IOS;
	init();
	dfs(1);
	cout << ans << endl;
	return 0;
}

F:成绩统计
#include 
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int sc[100000];
	int jige = 0, youxiu = 0;
	for(int i=1;i<=n;i++){
		cin >> sc[i];
		if(sc[i] >= 60)
			jige++;
		if(sc[i] >= 85)
			youxiu++;
	}
	float a, b;
	a = (float)jige / n * 100;
	b = (float)youxiu / n * 100;
	printf("%.0f%n%.0f%n",a,b);
	return 0;
}

G:回文日期

H:子串分值和
#include 
#include 
using namespace std;
string s;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int ans = 0;
	long long pre[30] = {0};//上次贡献位置 
	cin >> s;
	long long len = s.length();
	s = ' ' + s; 
	for(long long i=1;i<=len;i++){
		ans += (i-pre[s[i]-'a'])*(len-i+1);
		pre[s[i] - 'a'] = i;//记录上次位置 
	}
	cout << ans << endl;
	return 0;
}

I:平面切分

J:字串排序
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/717462.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号