A - ab
题意:判断字符串中是否有“ab”或者是“ba“
#include<bits/stdc++.h>
using namespace std;
void solve(){
int n;
cin>>n;
string s;
cin>>s;
if(s.find("ab")!=s.npos||s.find("ba")!=s.npos){
cout<<"Yes";
}else{
cout<<"No";
}
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)solve();
return 0;
}
B - A^A
题意:给定一个x,找到一个a,使得a^a是x
#include<bits/stdc++.h>
#define int unsigned long long
using namespace std;
void solve(){
int x;
cin>>x;
int f=0;
for(int i=1;i<=100;i++){
int t=1;
for(int j=1;j<=i;j++){
t=i*t;
if(t>x)break;
}
if(t==x){
f=1;
cout<<i;
break;
}
}
if(f==0){
cout<<-1;
}
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)solve();
return 0;
}
C - Number Place
题意:判断一个九宫格中每行每列以及均分成9个小块以后每种情况都是1~9唯一出现的
#include<bits/stdc++.h>
using namespace std;
int a[10][10];
void solve(){
for(int i=1;i<=9;i++){
for(int j=1;j<=9;j++){
cin>>a[i][j];
}
}
for(int i=1;i<=9;i++){
set<int>st;
set<int>st2;
for(int j=1;j<=9;j++){
st.insert(a[i][j]);
st2.insert(a[j][i]);
}
if(st.size()!=9||st2.size()!=9){
cout<<"No";
return;
}
}
set<int>b;
for(int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
b.insert(a[i][j]);
}
}
if(b.size()!=9){
cout<<"No";
return;
}
b.clear();
for(int i=4;i<=6;i++){
for(int j=1;j<=3;j++){
b.insert(a[i][j]);
}
}
if(b.size()!=9){
cout<<"No";
return;
}
b.clear();
for(int i=7;i<=9;i++){
for(int j=1;j<=3;j++){
b.insert(a[i][j]);
}
}
if(b.size()!=9){
cout<<"No";
return;
}
b.clear();
for(int i=1;i<=3;i++){
for(int j=4;j<=6;j++){
b.insert(a[i][j]);
}
}
if(b.size()!=9){
cout<<"No";
return;
}
b.clear();
for(int i=4;i<=6;i++){
for(int j=4;j<=6;j++){
b.insert(a[i][j]);
}
}
if(b.size()!=9){
cout<<"No";
return;
}
b.clear();
for(int i=7;i<=9;i++){
for(int j=4;j<=6;j++){
b.insert(a[i][j]);
}
}
if(b.size()!=9){
cout<<"No";
return;
}
b.clear();
for(int i=1;i<=3;i++){
for(int j=7;j<=9;j++){
b.insert(a[i][j]);
}
}
if(b.size()!=9){
cout<<"No";
return;
}
b.clear();
for(int i=4;i<=6;i++){
for(int j=7;j<=9;j++){
b.insert(a[i][j]);
}
}
if(b.size()!=9){
cout<<"No";
return;
}
b.clear();
for(int i=7;i<=9;i++){
for(int j=7;j<=9;j++){
b.insert(a[i][j]);
}
}
if(b.size()!=9){
cout<<"No";
return;
}
cout<<"Yes";
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)solve();
return 0;
}
标签:AtCoder,ab,题意,Beginner,int,namespace,solve,327,include
From: https://www.cnblogs.com/yufan1102/p/17814075.html