2022河南CCPC(前四题)

签到题目

cpp 复制代码
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define PII pair<int,int>
#define fi first
#define se second
#define endl '\n'
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

void solve()
{
	int n;
	cin>>n;
	if(n>10)
	{
		cout<<"-1"<<endl;
		return ;
	} 
	else if(n==1)
	{
		cout<<1<<endl;
		return ;
	}
	else
	{
		cout<<"10";
		for(int i=2;i<n;i++)
		{
			cout<<i;
		}
	}
}

signed main()
{
	IOS
	int T=1;
//	cin>>T;
	while(T--) solve(); 
	return 0;
} 
cpp 复制代码
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define PII pair<int,int>
#define fi first
#define se second
#define endl '\n'
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

void solve()
{
	int n;
	cin>>n;cin.ignore();
	string s;
	cin>>s;
	char ff='*',ss='*',tt='*';
	int index=0;
	unordered_map<char,int> mp;
	for(int i=0;i<s.size();i++)
	{
		mp[s[i]]++;
		if(mp[s[i]]==5)
		{
			ff=s[i];
			index=i;
			break;
		}
	}
	mp.clear();
	for(int i=index+1;i<s.size();i++)
	{
		mp[s[i]]++;
		if(mp[s[i]]==7)
		{
			ss=s[i];
			index=i;
			break;
		}
	}
	mp.clear();
	for(int i=index+1;i<s.size();i++)
	{
		mp[s[i]]++;
		if(mp[s[i]]==5)
		{
			tt=s[i];
			index=i;
			break;
		}
	}
	if(ff!='*'&&ss!='*'&&tt!='*')
	{
		for(int i=0;i<5;i++) cout<<ff;
		for(int i=0;i<7;i++) cout<<ss;
		for(int i=0;i<5;i++) cout<<tt;
		cout<<endl;
		return ;
	}
	else
	{
		cout<<"none"<<endl;
		return ;
	}
}

signed main()
{
	IOS
	int T=1;
//	cin>>T;
	while(T--) solve(); 
	return 0;
} 

答案不唯一:

cpp 复制代码
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define PII pair<int,int>
#define fi first
#define se second
#define endl '\n'
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

void solve()
{
	int n;
	cin>>n;
	if(n==2||n==4)
	{
		cout<<"-1"<<endl;
		return ;
	}
	if(n&1)
	{
		n++;
		n/=2;
		cout<<n<<endl;
		for(int i=0;i<n;i++) cout<<i<<' ';
	}
	else
	{
		cout<<n/2<<endl;
		for(int i=0;i<=(n/2);i++)
		if(i!=1)
		cout<<i<<' ';
	}
}

signed main()
{
	IOS
	int T=1;
//	cin>>T;
	while(T--) solve(); 
	return 0;
} 

或:

cpp 复制代码
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define PII pair<int,int>
#define fi first
#define se second
#define endl '\n'
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

void solve()
{
	int n;
	cin>>n;
	if(n==2||n==4)
	{
		cout<<"-1"<<endl;
		return ;
	}
	if(n&1)
	{
		n++;
		n/=2;
		cout<<n<<endl;
		for(int i=0;i<n;i++) cout<<i<<' ';
	}
	else
	{
		cout<<n/2<<endl;
		n/=2;
		for(int i=1;i<n;i++) cout<<i<<' ';
		cout<<n+1;
	}
}

signed main()
{
	IOS
	int T=1;
//	cin>>T;
	while(T--) solve(); 
	return 0;
} 
cpp 复制代码
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define PII pair<int,int>
#define fi first
#define se second
#define endl '\n'
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
const int mod = 998244353;
void solve()
{
	int n,m;cin>>n>>m;
	vector<string> a(n);
	for(int i=0;i<n;i++) cin>>a[i];
	int q;cin>>q;
	while(q--)
	{
		int x,b,c,d,e;//与操作和操作次数无关  如果有0与运算后整列都是0 计算期望时也为0 都是1的话相当于概率为100%或者0% 没变 
		cin>>x>>b>>c>>d>>e;
	}
	int cnt=0;
	for(int i=0;i<m;i++)
	{
		bool ff=1;
		for(int j=0;j<n;j++)
		{
			if(a[j][i]=='0')
			{
				ff=0;
			}
		}
		if(ff) cnt++;
	}
	cout<<cnt%mod<<endl;
}

signed main()
{
	IOS
	int T=1;
//	cin>>T;
	while(T--) solve(); 
	return 0;
} 
相关推荐
GentleDevin13 小时前
Mac 常用快捷键速查表
macos
GOU9214 小时前
5101实验
网络·macos
柯儿的天空15 小时前
【OpenClaw 全面解析:从零到精通】第 005 篇:OpenClaw 在 macOS 上的安装与部署实战
人工智能·macos·自然语言处理·ai作画
@大迁世界18 小时前
液态玻璃屏正在侵蚀你的电池
macos·ios·objective-c·cocoa
liangshanbo121518 小时前
[特殊字符] macOS 上的 zoxide:智能目录跳转终极指南
macos·策略模式
pop_xiaoli19 小时前
【iOS】类与对象底层
macos·ios·objective-c·cocoa·xcode
2501_9159214319 小时前
常用iOS性能测试工具大全及使用指南
android·测试工具·ios·小程序·uni-app·cocoa·iphone
一招定胜负20 小时前
视频转写+LLM分析:课堂录音自动化处理实现
macos·ios·xcode
坚果派·白晓明21 小时前
在 macOS 中搭建鸿蒙 PC 三方库交叉编译开发环境
macos·华为·harmonyos
blackorbird21 小时前
通过攻陷合法网站传播的新型iOS漏洞利用工具包DarkSword
macos·ios·objective-c·cocoa