A.模拟
//Lanthanmum
#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 a,b,c;
cin>>a>>b>>c;
if(a<b && b<c && a<c){
cout<<"STAIR"<<'\n';
}else if(a<b && b>c){
cout<<"PEAK"<<'\n';
}else{
cout<<"NONE"<<'\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int q;
cin>>q;
while (q--) {
Lan();
}
return 0;
}
B.模拟
//Lanthanmum
#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;
n*=2;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if((i>>1 ^ j>>1) &1){
cout<<".";
}else{
cout<<"#";
}
}
cout<<'\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int q;
cin>>q;
while (q--) {
Lan();
}
return 0;
}
C.模拟
#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
char a[N];
void Lan(){
for(int i=1;i<=5;i++){
cin>>a[i];
}
ll h=(a[1]-'0')*10+(a[2]-'0');
ll min=(a[4]-'0')*10+(a[5]-'0');
if(h>=12){//pm
h-=12;
if(!h){
h=12;
}
if(h<10){
if(min<10){
cout<<"0"<<h<<":"<<"0"<<min<<" "<<"PM"<<'\n';
}else{
cout<<"0"<<h<<":"<<min<<" "<<"PM"<<'\n';
}
}else{
if(min<10){
cout<<h<<":"<<"0"<<min<<" "<<"PM"<<'\n';
}else{
cout<<h<<":"<<min<<" "<<"PM"<<'\n';
}
}
}else{
if(!h){
h=12;
}
if(h<10){
if(min<10){
cout<<"0"<<h<<":"<<"0"<<min<<" "<<"AM"<<'\n';
}else{
cout<<"0"<<h<<":"<<min<<" "<<"AM"<<'\n';
}
}else{
if(min<10){
cout<<h<<":"<<"0"<<min<<" "<<"AM"<<'\n';
}else{
cout<<h<<":"<<min<<" "<<"AM"<<'\n';
}
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int q;
cin>>q;
while (q--) {
Lan();
}
return 0;
}
D.暴力枚举
//Lanthanmum
#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
int t[33] = {1,10, 11, 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111, 10000, 10001, 10010, 10011, 10100, 10101, 10110, 10111, 11000, 11001, 11010, 11011, 11100, 11101, 11110, 11111, 100000,0};
set<ll> st;
void init(){
// int n;
// cin>>n;
//100000
//状压dp
for(int i=0;i<=32;i++){
if(t[i]>100000){
break;
}
for(int j=0;j<=32;j++){
if(t[i]*t[j]>100000){
break;
}
for(int k=0;k<=32;k++){
if(t[i]*t[j]*t[k]>100000){
break;
}
for(int l=0;l<=32;l++){
if(t[i]*t[j]*t[k]*t[l]>100000){
break;
}
for(int r=0;r<=32;r++){
ll res=t[i]*t[j]*t[k]*t[l]*t[r];
st.insert(res);
}
}
}
}
}
}
void Lan(){
int n;
cin>>n;
if(st.count(n)){
cout<<"YES"<<'\n';
}else{
cout<<"NO"<<'\n';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
init();
int q;
cin>>q;
while (q--) {
Lan();
}
return 0;
}
E.枚举字符串长度的因数,找到满足题意的最大字符串长度,输出需要几个这样的长度
//Lanthanmum
#include<bits/stdc++.h>
#define eps 1e-5
#define INF 1e9
using namespace std;
typedef long long ll;
const int N = 2e6 + 9;
string s;
int n;
bool check(int len){
ll res=0;
int part=n/len;
for(int i=0;i<len;i++){
int a[30]={};
int mxnum=0;
for(int j=i;j<n;j+=len){
int num=s[j]-'a';
a[num]++;
mxnum=max(mxnum,a[num]);
}
res+=part-mxnum;
}
return res<=1;
}
void Lan(){
cin>>n;
cin>>s;
int ans=n;
for(int i=1;i<=n;i++){
if(n%i){
continue;
}
if(check(i)){
ans=min(ans,i);
}
if(check(n/i)){
ans=min(ans,n/i);
}
}
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;
}
F.二叉树性质,模拟建树
//Lanthanmum
#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 a,b,c;
cin>>a>>b>>c;
if(a+1!=c){
cout<<-1<<'\n';
}else{//模拟
queue<int> q;
q.push(0);
ll ans=0;
while(!q.empty()){
int x=q.front();
q.pop();
ans=x;
if(a){
a--;
q.push(x+1);
q.push(x+1);
}else if(b){
b--;
q.push(x+1);
}
}
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;
}