第四届“传智杯”全国大学生IT技能大赛(练习赛)

4 篇文章 4 订阅

据说正式赛要难一点。

符合条件的数

可能输入的数就满足条件的。

#include <iostream>
using namespace std;
long long k ;
bool check(long long x)
{   int cnt = 0;
	while(x)
	{
		if(x % 10 == 3) cnt ++;
		x/=10;
	}
	return cnt == k;
}
int main()
{    
	long long  n;
	cin >> n >> k;
	
	for(long long  i = n ;;i++)
	{
		if(check(i))
		{
			 cout << i << endl;
			 break;
		}
	}
	return 0;
 } 

选代表

 

#include <iostream>
#include <map>
using namespace std;
map<int,int>m;
int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n ; i++)
	{
		int a;
        cin >> a;	
	  if(m[a] == 0) 
	  {
	  	 cout << a << ' ';
	  	 m[a] = 1;
	  }
	}
			
	return 0;
 } 

成绩统计

 

 

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

struct node {
	string name;
	int a,b,sum,id;
}e[1000];
int cmp(node x,node y)
{
	if(x.sum != y.sum) return x.sum > y.sum;
	else return x.id < y .id;
}
int main()
{
	int n;
	cin >> n;
	
	for(int i = 0; i< n ;i++)
	{    e[i].id = i;
		 cin >> e[i].name >> e[i].a >> e[i].b;
		 double c = (sqrt(e[i].b)*10);
		 if(c == (int)c) e[i].b = (int)c;
		 else {
		 	e[i].b = (int)c  + 1;
		 }
		  e[i].sum = round(e[i].b *0.6 + e[i].a *0.4);		 
 	}
 	sort(e,e+n,cmp);
 	for(int i = 0; i<n;i++)
 	{
 		cout << e[i].name << ' ' << e[i]. sum << endl;
	 }
	
	return 0;
 } 

背答案

 

 

#include <iostream>
using namespace std;
struct node{
	string w,d;
}e[1000];
int main()
{
	int n,q;
	cin >> n >> q;	
	for(int i = 0; i < n;i++)
	{
		cin >> e[i].w >> e[i].d;		
	}
	while(q--)
	{
		int cnt = 0;
		string a;
		cin >> a;
		int s;
		for(int i =0;i < n;i++)
			{
				if(e[i].w == a)
				{
					s = i;break;
				}
			}
		for(int i = 0;i < 4;i++)
		{   
			string b;
			cin >> b;
			if(e[s].d == b)
			{
				cout << (char)(65+cnt) << endl;
			}
			cnt ++;
		}	
		
	}
	
	return 0;
 } 

击鼓传花

 

#include <iostream>
using namespace std;

const int N = 1000010;
int m1[N];
int n,m,k;

inline int read()
{
    int x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0'){if(ch == '-')f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x * 10 + ch - '0';ch = getchar();}
    return x * f;
}

void check(int x)
{   

	for(int i = x;;i = (i + k) % n)
	{   
	    if(m1[i] == 1) break;
		m1[i] = 1;
	}
		    
}
int main()
{
		
	n = read(),m = read(),k =read();
    while(m--) 
	{    
	    int j;
	    j = read();
		if(m1[j] == 0)
		  check(j);			
	}
	int ans= 0;
	for(int i = 0;i < n;i++)
	{
		if(m1[i] == 0) ans++;
	}
	printf("%d\n",ans);
	
	return 0;
 } 

  • 9
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值