https://codeforces.com/contest/1974/problem/A
946
A 计算出2*2屏幕所需要的方格 然后计算出剩余出1的格子,相除算出个数不够加一
# include <bits/stdc++.h>
using namespace std;
# define int long long
signed main()
{
int T;
cin>>T;
while(T--)
{
int a,b;
cin>>a>>b;
int t=b/2+(b%2==1);
// cout<<t<<endl;
a-=t*15-b*4;
//cout<<a<<endl;
if(a>=0)
{
t+=a/15+(a%15!=0);
cout<<t;
}
else cout<<t;
cout<<endl;
}
return 0;
}
B
本题需要搞懂本体的操作意思,答案操作后变成给出的字符,但是辅助字符串时相同的,对输入用辅助字符串操作后由于字符对称,即可还原成原答案。
# include <bits/stdc++.h>
using namespace std;
# define int long long
# define x first
# define y second
signed main()
{
int T;
cin>>T;
while(T--)
{
int n;
string s,r="";
cin>>n>>s;
map<char,int>ma;
vector<char>a;
for(int i=0;i<n;i++)
{
ma[s[i]]++;
}
for(auto t:ma)
{
a.push_back(t.x);
}
map<char,char>da;
int len=a.size();
for(int i=0;i<len;i++)
{
da[a[i]]=a[len-i-1];
}
for(int i=0;i<=n-1;i++)
s[i]=da[s[i]];
cout<<s<<endl;
}
return 0;
}
C
考察组合数学,分类讨论。对于三元组满足两两相等的条件即对组合答案有贡献,但要注意三个完全相等的情况减去其对于答案的贡献了 用map储存计算答案
# include <bits/stdc++.h>
using namespace std;
# define int long long
# define x first
# define y second
const int N=2e5+10;
int n;
signed main()
{
int T;
cin>>T;
while(T--)
{
cin>>n;
vector<int>a(n+1,0);
for(int i=1;i<=n;i++)
cin>>a[i];
map<pair<int,int>,int>a1;
map<pair<int,int>,int>a2;
map<pair<int,int>,int>a3;
map<array<int,3>,int>b;
for(int i=2;i<n;i++)
{
a1[{a[i-1],a[i]}]++;
a2[{a[i-1],a[i+1]}]++;
a3[{a[i],a[i+1]}]++;
b[{a[i-1],a[i],a[i+1]}]++;
}
int sum=0;
for(auto t:a1)
{
if(t.y>=2)
sum+=t.y*(t.y-1)/2;
}
for(auto t:a2)
{
if(t.y>=2)
sum+=t.y*(t.y-1)/2;
}
for(auto t:a3)
{
if(t.y>=2)
sum+=t.y*(t.y-1)/2;
}
for(auto &[e,f]:b)
{
if(f>=2)
sum-=3*f*(f-1)/2;
}
cout<<sum<<endl;
}
return 0;
}
960
A
考察博弈内容 如果每个数出现的次数都为偶数那么对于另一个人即可以一直模仿,因此爱丽丝会输
# include <bits/stdc++.h>
using namespace std;
# define int long long
# define x first
# define y second
const int N=52;
int a[N];
signed main()
{
int T;
cin>>T;
while(T--)
{
int n;
cin>>n;
map<int,int>ma;
for(int i=1;i<=n;i++)
cin>>a[i],ma[a[i]]++;
sort(a+1,a+n+1);
bool st=0;
for(auto t:ma)
if(t.y%2==1)
st=1;
if(st)cout<<"YES";
else cout<<"NO";
cout<<endl;
}
}
B
# include <bits/stdc++.h>
using namespace std;
# define int long long
const int N=1e5+10;
int a[N]={0};
signed main()
{
int T;
cin>>T;
while(T--)
{
int n,x,y;
cin>>n>>x>>y;
if(x<y)swap(x,y);
for(int i=y;i<=x;i++)
a[i]=1;
a[x+1]=-1;
a[y-1]=-1;
//for(int i=1;i<=n;i++)
//cout<<a[i]<<" ";
for(int i=y-2;i>0;i--)
{
if(a[i+1]==-1)
a[i]=1;
else
a[i]=-1;
}
for(int i=x+2;i<=n;i++)
{
if(a[i-1]==1)
a[i]=-1;
else
a[i]=1;
}
for(int i=1;i<=n;i++)
cout<<a[i]<<" ";
cout<<endl;
}
return 0;
}