A-奇偶判断
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const LL N=200200;
LL a[N],b[N];
#define x first
#define y second
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
int T=1;
// cin>>T;
while(T--)
{
string s;
cin>>s;
int len=s.size();
if((s[len-1]-'0')%2==0) cout<<"0"<<endl;
else cout<<"1"<<endl;
}
return 0;
}
B-字母补全
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const LL N=200200;
map<char,int> mp;
bool check(string c)
{
mp.clear();
for(int j=0;j<c.size();j++)
{
mp[c[j]]++;
if(c[j]!='?'&&mp[c[j]]==2) return false;
}
return true;
}
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
int T=1;
// cin>>T;
while(T--)
{
string s;
cin>>s;
string c;
bool flag=false;
int i;
for(i=0;i<s.size();i++)
{
if(i+25<s.size())
{
c=s.substr(i,26);
if(check(c)==true)
{
flag=true;
break;
}
}
else break;
}
if(flag==false) cout<<"-1"<<endl;
else
{
//cout<<i<<endl;
for(int k=i;k<i+c.size();k++)
{
if(c[k-i]=='?')
{
for(int j=0;j<26;j++)
{
char op=65+j;
if(count(c.begin(),c.end(),op)==0)
{
c[k-i]=op;
break;
}
}
}
}
for(int j=0;j<s.size();j++)
{
if(j==i)
{
cout<<c; j+=25;
}
else if(s[j]=='?') cout<<"A";
else cout<<s[j];
}
}
}
return 0;
}
C-整数分组
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const LL N=200200;
LL a[N];
int main()
{
cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
int T=1;
// cin>>T;
while(T--)
{
int n;
cin>>n;
map<int,int> mp;
for(int i=1;i<=n;i++)
{
cin>>a[i];
mp[a[i]]++;
}
int s1=0,s2=0,s3=0;
for(int i=1;i<=100;i++)
{
if(mp[i]==1) s1++;
else if(mp[i]==2) s2++;
else if(mp[i]>=3) s3++;
}
if((s1+2*s2)%2==1&&s3==0) cout<<"NO"<<endl;
else
{
cout<<"YES"<<endl;
if(s1%2==0)
{
int sum=0;
for(int i=1;i<=n;i++)
{
if(mp[a[i]]==1)
{
if(sum%2==1) cout<<"A";
else cout<<"B";
sum++;
}
else cout<<"A";
}
}
else
{
bool idx=false;
int l=0,r=0;
for(int i=1;i<=n;i++)
{
if(mp[a[i]]==1)
{
if(l<=r) { cout<<"A"; l++; }
else { cout<<"B"; r++; }
}
else if(mp[a[i]]==2) cout<<"A";
else if(mp[a[i]]>=3)
{
if(idx==false)
{
cout<<"B";
r++;
idx=true;
}
else
{
cout<<"A";
}
mp[a[i]]=2;
}
}
}
}
}
return 0;
}
标签:周赛,typedef,ABC,cout,int,LL,cin,long,66
From: https://www.cnblogs.com/Vivian-0918/p/16631434.html