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;
} 
相关推荐
ElenaYu1 天前
mac安装whistle代理抓包工具(支持mock)
macos·抓包工具
大熊猫侯佩1 天前
SwiftUI 5.0(iOS 17.0,macOS 14.0+)新 Inspector 辅助视图之趣味漫谈
macos·ios·swiftui
guiyanakaung2 天前
一篇文章让你学会 Compose Multiplatform 推荐的桌面应用打包工具 Conveyor
android·windows·macos
a4576368762 天前
Objective-c Block 面试题
开发语言·macos·objective-c
咧咧小侠2 天前
群控 iPhone(免越狱)自动化系统搭建构想
自动化·cocoa·iphone
Sunshine~L&H2 天前
Mac 上使用 mysql -u root -p 命令,出现“zsh: command not found: mysql“?如何解决
数据库·mysql·macos
a4576368763 天前
Objective-c protocol 练习
开发语言·macos·objective-c
BAGAE3 天前
Flutter 与原生技术(Objective-C/Swift,java)的关系
java·开发语言·macos·objective-c·cocoa·智慧城市·hbase
RocketJ3 天前
mac电脑.sh文件,用来清除git当前分支
git·elasticsearch·macos
2501_922232943 天前
Mac电脑 系统监测工具 System Dashboard Pro
macos