4606. 奇偶判断
题目链接:奇偶判断
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double eps=1e-7;
const int base=131;
#define x first
#define y second
#define int long long
#define lb long double
#define ull unsigned long long
#define pb push_back
#define endl '\n'
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define dwn(i,n,x) for(int i=n;i>=x;i--)
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
int Mod(int a,int mod){return (a%mod+mod)%mod;}
int lowbit(int x){return x&-x;}//最低位1及其后面的0构成的数值
int qmi(int a, int k, int p){int res = 1 % p;while (k){if (k & 1) res = Mod(res * a , p);a = Mod(a * a , p);k >>= 1;}return res;}
int inv(int a,int mod){return qmi(a,mod-2,mod);}
void solve()
{
string s;
cin>>s;
int x=s.back()-'0';
if(x%2)cout<<1<<endl;
else cout<<0<<endl;
}
signed main()
{
io;
int _;_=1;
// cin>>_;
while(_--)solve();
return 0;
}
4607. 字母补全
题目链接:字母补全
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double eps=1e-7;
const int base=131;
#define x first
#define y second
#define int long long
#define lb long double
#define ull unsigned long long
#define pb push_back
#define endl '\n'
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define dwn(i,n,x) for(int i=n;i>=x;i--)
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
int Mod(int a,int mod){return (a%mod+mod)%mod;}
int lowbit(int x){return x&-x;}//最低位1及其后面的0构成的数值
int qmi(int a, int k, int p){int res = 1 % p;while (k){if (k & 1) res = Mod(res * a , p);a = Mod(a * a , p);k >>= 1;}return res;}
int inv(int a,int mod){return qmi(a,mod-2,mod);}
void solve()
{
string s;
cin>>s;
map<char,int>mp;
for(int l=0;l+26-1<s.size();l++)
{
mp.clear();
int r=l+26-1;
bool f=false;
for(int k=l;k<=r;k++)
{
if(s[k]!='?'&&mp.count(s[k]))
{
f=true;
break;
}
else mp[s[k]]++;
}
if(f)continue;
else
{
vector<char>v;
for(char c='A';c<='Z';c++)
if(!mp.count(c))
v.pb(c);
for(int k=l,cnt=0;k<=r;k++)
if(s[k]=='?')
s[k]=v[cnt++];
for(int i=0;i<s.size();i++)
if(s[i]=='?')s[i]='A';
cout<<s<<endl;
return;
}
}
cout<<-1<<endl;
}
signed main()
{
io;
int _;_=1;
// cin>>_;
while(_--)solve();
return 0;
}
4608. 整数分组
题目链接:整数分组
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const double eps=1e-7;
const int base=131;
#define x first
#define y second
#define int long long
#define lb long double
#define ull unsigned long long
#define pb push_back
#define endl '\n'
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define rep(i,x,n) for(int i=x;i<=n;i++)
#define dwn(i,n,x) for(int i=n;i>=x;i--)
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
int Mod(int a,int mod){return (a%mod+mod)%mod;}
int lowbit(int x){return x&-x;}//最低位1及其后面的0构成的数值
int qmi(int a, int k, int p){int res = 1 % p;while (k){if (k & 1) res = Mod(res * a , p);a = Mod(a * a , p);k >>= 1;}return res;}
int inv(int a,int mod){return qmi(a,mod-2,mod);}
int n;
const int N=110;
int a[N];
void solve()
{
cin>>n;
rep(i,1,n)cin>>a[i];
map<int,int>mp;
int cnt=0;
rep(i,1,n)
mp[a[i]]++;
for(auto x:mp)
if(x.y==1)cnt++;
if(cnt%2==0)
{
string s;
int res=cnt/2;
rep(i,1,n)
{
if(res&&mp[a[i]]==1)s+='A',res--;
else s+='B';
}
cout<<"YES"<<endl;
cout<<s<<endl;
return;
}
else
{
string s;
for(auto x:mp)
{
if(x.y>2)
{
bool f=false;
int res=cnt/2;
rep(i,1,n)
{
if(a[i]==x.x)
{
if(!f)
{
f=true;
s+='A';
}
else s+='B';
}
else
{
if(res&&mp[a[i]]==1)s+='A',res--;
else s+='B';
}
}
cout<<"YES"<<endl;
cout<<s<<endl;
return;
}
}
}
cout<<"NO"<<endl;
}
signed main()
{
io;
int _;_=1;
// cin>>_;
while(_--)solve();
return 0;
}