Codeforces Round #634 (Div. 3)

在这里插入图片描述太菜了只会前四道水题
菜鸡也想发一下自己的代码,明天把E1补上:
A:Candies and Two Sisters

#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
	int a;
	cin>>a;
	while(a--)
	{
        int n;
		cin>>n;
		cout<<n-n/2-1<<endl;	
	}
	return 0;
} 

这题及其水,在纸上画画就出了

B. Construct the String

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
	int y;
	cin>>y;
	while(y--)
	{
		int n,a,b;
		cin>>n>>a>>b;
		int i;
		int x=1;
		int flag=0;
		if(b==1)
		{
			flag=1;
			for(i=1;i<=n;i++)
			{
				char s='a';
				cout<<s;
			}
		}
		if(flag)
		{
			cout<<endl;
			continue;
		}
		for(i=1;i<=n;i++)
		{
			if(i%b==1)
			{
				x=1;
			}
            char s='a'+x-1;
            x++;
            cout<<s;
		}
		cout<<endl;
	}
	return 0;
}

这题看b就行了,循环节就能做

CTwo Teams Composing

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
using namespace std;
const int N=2e5+10;
vector<int> v;
int mark[N]={0};
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		memset(mark,0,sizeof mark);
		while(v.size())
		{
			v.pop_back();
		}
		int n;
		cin>>n;
		int maxx=-1;
		for(int i=1;i<=n;i++)
		{
			int x;
			cin>>x;
			v.push_back(x);
			mark[x]++;
			maxx=max(mark[x],maxx);
		}
		sort(v.begin(),v.end());
		vector<int>::iterator it=unique(v.begin(),v.end());
		v.erase(it,v.end());
		//for(int i=0;i<v.size();i++) cout<<v[i]<<" ";
	    if(maxx==v.size())
		{
			cout<<maxx-1<<endl;
		}else if(maxx>v.size())
		{
			cout<<v.size()<<endl;
		}else
		{
			cout<<maxx<<endl;
		}
	}
	return 0;
}

这题就是先把数列存在vector里,输入的同时记录下那个数字出现的次数最多并记录次数(maxx),然后将数组排序后去重,把vector去重后的末尾数删去,此时有3种情况:若maxx>v.size(),则此时选择最小的。若maxx=v.size(),则此时选择谁都行但要-1。若maxx<v.size(),则选择最小的。

D. Anti-Sudoku

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
using namespace std;
string s[9];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		for(int i=0;i<9;i++)
		{
			cin>>s[i];
		}
		for(int i=0;i<9;i++)
		{
			for(int j=0;j<9;j++)
			{
				if(s[i][j]=='1')
				{
					s[i][j]='2';
				}
			}
		}
		for(int i=0;i<9;i++)
		{
			cout<<s[i]<<endl;
		}
	}
	return 0;
}

由图知:将1换2就行

E1:明天补

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值