A.
// Problem: A. Vlad and the Best of Five
// Contest: Codeforces - Codeforces Round 928 (Div. 4)
// URL: https://codeforces.com/contest/1926/problem/0
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N];
void Lan(){
string s;
cin>>s;
int cnta=0;
for(int i=0;i<s.size();i++){
cnta+=(s[i]=='A');
}
int cntb=(int)(s.size())-cnta;
if(cntb>cnta){
cout<<"B"<<'\n';
}else{
cout<<"A"<<'\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int q;
cin>>q;
while (q--) {
Lan();
}
return 0;
}
B.
观察图片或者正方形性质
// Problem: B. Vlad and Shapes
// Contest: Codeforces - Codeforces Round 928 (Div. 4)
// URL: https://codeforces.com/contest/1926/problem/B
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e3 + 9;
int a[N][N];
void Lan(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
char c;
cin>>c;
if(c=='1'){
a[i][j]=1;
}else{
a[i][j]=0;
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
if(a[i][j]==1){
if(!a[i][j+1] || !a[i+1][j]){
cout<<"TRIANGLE"<<'\n';
return;
}else{
cout<<"SQUARE"<<'\n';
return;
}
}
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int q;
cin>>q;
while (q--) {
Lan();
}
return 0;
}
C.
前缀和打表,学到了
// Problem: C. Vlad and a Sum of Sum of Digits
// Contest: Codeforces - Codeforces Round 928 (Div. 4)
// URL: https://codeforces.com/contest/1926/problem/C
// Memory Limit: 256 MB
// Time Limit: 500 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e5 + 9;
int prefix[N],a[N];
namespace Lan {
inline string sread() {
string s=" ";char e=getchar();
while(e==' '||e=='\n')e=getchar();
while(e!=' '&&e!='\n')s+=e,e=getchar();
return s;
}
inline void swrite(string s){
for(char e:s)putchar(e);
printf("\n");
}
inline ll read() {
ll x=0,y=1;char c=getchar();
while(!isdigit(c)){if(c=='-')y=-1;c=getchar();}
while(isdigit(c)){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
return x*=y;
}
inline void write(ll x) {
if(x<0)x=-x,putchar('-');ll sta[35],top=0;
do sta[top++]=x%10,x/=10;while(x);
while(top)putchar(sta[--top]+'0');
}
}using namespace Lan;
int solve(string x){
ll res=0;
for(int i=0;i<x.size();i++){
res+=(x[i]-'0');
}
return res;
}
void lan(){
int n;
n=read();
write(prefix[n]);
putchar('\n');
}
void init(){
for(int i=1;i<=200000;i++){//打表前缀和处理
a[i]=solve(to_string(i));
}
for(int i=1;i<=200000;i++){
prefix[i]=prefix[i-1]+a[i];
}
}
int main() {
// ios::sync_with_stdio(false);
// cin.tie(0),cout.tie(0);
init();
int q;
q=read();
while (q--) {
lan();
}
return 0;
}
D.
题意理解发现是xor操作
// Problem: D. Vlad and Division
// Contest: Codeforces - Codeforces Round 928 (Div. 4)
// URL: https://codeforces.com/contest/1926/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N];
void Lan(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
}
map<int,int> mp;
ll ans=0;
for(int i=1;i<=n;i++){
if(mp[a[i]^INT_MAX]){//如果有配对的就可以在一组
mp[a[i]^INT_MAX]--;
}else{//没有无法配对
mp[a[i]]++;
ans++;
}
}
cout<<ans<<'\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int q;
cin>>q;
while (q--) {
Lan();
}
return 0;
}
E.
// Problem: E. Vlad and an Odd Ordering
// Contest: Codeforces - Codeforces Round 928 (Div. 4)
// URL: https://codeforces.com/contest/1926/problem/E
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int a[N];
void Lan(){
int n,k;
cin>>n>>k;
int t=n;
int cur=1;
while(t){
int pos=t-t/2;
if(k<=pos){//在这一轮
cout<<cur*(2*k-1)<<'\n';
return;
}
k-=pos;//超过
cur*=2;//1248
t/=2;
}
// int cnt=0;进行次数
// while(k>(n+1)/2){
// int num=(n+1)/2;
// k-=num;
// n/=2;
// cnt++;
// }
// cout<<((2*k-1)<<cnt)<<'\n';//an=a1+(n-1)*d;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int q;
cin>>q;
while (q--) {
Lan();
}
return 0;
}
1420

被折叠的 条评论
为什么被折叠?



