A:
点击查看代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
if(n<0)
{
cout<<"-";
}
n=abs(n);
bool b=0;
while(n>0)
{
if(n%10!=0)
{
cout<<n%10;
b=1;
}
else if(b==1)
{
cout<<n%10;
}
n/=10;
}
return 0;
}
B:
点击查看代码
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>s1>>s2;
int len=s1.size();
for(int i=1;i<=len+1;i++){
//cout<<s1<<' ';
int q=-1;
q=s1.find(s2);
if(q!=-1){
cout<<"true\n";
return 0;
}
char c=s1[0];
s1.erase(0,1);
s1.push_back(c);
}
cout<<"false\n";
return 0;
}
C:
点击查看代码
#define love int
#define ccf main
#include<bits/stdc++.h>
using namespace std;
love ccf()
{
string s[105];
string replace,bereplaced;
int i=0;
while(cin>>s[i++]);
replace=s[i-2];
bereplaced=s[i-3];
for(int j=0;j<i-3;j++)
{
if(s[j]==bereplaced)
{
cout<<replace<<" ";
}
else
{
cout<<s[j]<<" ";
}
}
return 0;
}
D:
点击查看代码
#include<bits/stdc++.h>
using namespace std;
string s1,s2,ss1,ss2,k;
int l1,l2,ans=-114514,f=-1;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>s1>>s2;
ss1=s1+s1,ss2=s2+s2;
l1=ss1.size();
l2=ss2.size();
if(l1>l2){
swap(ss1,ss2);
l1=ss1.size();
l2=ss2.size();
}
//cout<<ss1<<ss2<<"\n";
for(int i=0;i<l1/2;i++){
for(int j=1;j<=l1/2;j++){
f=ss2.find(ss1.substr(i,j));
if(f!=-1){
if(j>ans) ans=j;
}
}
}
cout<<ans<<"\n";
return 0;
}
E:
点击查看代码
#include<bits/stdc++.h>
using namespace std;
int n;
const int N=114514;
struct nb{
int m,d;
string name;
nb(int a,int b,string c) : m(a),d(b),name(c){}
nb(){}
bool operator<(const nb&wow) const{
if(m!=wow.m){
return m<wow.m;
}
if(d!=wow.d){
return d<wow.d;
}
if(name.size()!=wow.name.size()){
return name.size()<wow.name.size();
}
return name<wow.name;
}
}NBA[N];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=1;i<=n;i++){
cin>>NBA[i].name>>NBA[i].m>>NBA[i].d;
}
sort(NBA+1,NBA+n+1);
int dd=NBA[1].d,mm=NBA[1].m;
string nn=NBA[1].name;
int ff=0;
for(int i=2;i<=n;i++){
if(NBA[i].m==mm && NBA[i].d==dd){
if(ff==0) cout<<mm<<" "<<dd<<" "<<nn<<" ";
cout<<NBA[i].name<<" ";
ff=1;
}
else if(ff==1){
cout<<"\n";
ff=0;
dd=NBA[i].d,mm=NBA[i].m;
nn=NBA[i].name;
}
else{
ff=0;
}
}
return 0;
}
F:
点击查看代码
#include<bits/stdc++.h>
using namespace std;
int n;
struct birth{
string name;
int y,m,d;
}p[103];
bool cmp(birth a,birth b){
if(a.y!=b.y) return a.y<b.y;
else if(a.m!=b.m) return a.m<b.m;
else if(a.d!=b.d) return a.d<b.d;
else return a.name>b.name;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>p[i].name>>p[i].y>>p[i].m>>p[i].d;
}
sort(p+1,p+1+n,cmp);
for(int i=1;i<=n;i++){
cout<<p[i].name<<endl;
}
return 0;
}
G:
点击查看代码
#include<bits/stdc++.h>
using namespace std;
int n;
#define N 10005
char s1[N],s2[N],s3[N];
inline int solve(char a[],char b[],char c[]){
char s4[N],s5[N],s6[N];
for(int i=0;i<n;i++){
s4[i]=a[n-i-1];
}
for(int k=0;k<=6;k++){
for(int i=0;i<n;i++){
s5[i]=(b[i]+k-'a')%26+'a';
}
for(int i=0;i<n;i++){
s6[i]=((c[i]-k-'a')+26)%26+'a';
}
int opt=1;
for(int i=0;i<n;i++){
if(s4[i]!=s5[i] || s4[i]!=s6[i] || s5[i]!=s6[i]){
opt=0;
}
}
if(opt==1){
for(int i=0;i<n;i++){
cout<<s4[i];
//cout<<"qwq";
}
return 1;
}
}
return 0;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
cin>>s1>>s2>>s3;
if(solve(s1,s2,s3)) return 0;
if(solve(s1,s3,s2)) return 0;
if(solve(s2,s1,s3)) return 0;
if(solve(s2,s3,s1)) return 0;
if(solve(s3,s1,s2)) return 0;
if(solve(s3,s2,s1)) return 0;
return 0;
}
H:
点击查看代码
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+100;
#define ll long long
#define ull unsigned long long
int t,n;
ull int8=127,uint8=255,int16=32767,uint16=65535,int32=2147483647;
ull uint32=4294967295,int64=9223372036854775807;
ull uint64=18446744073709551615;
char s[15],a[N];
int num;
ull mx;
int flag,jd=0;
int pd[25]={0,1,8,4,4,6,7,4,4,0,7,3,7,0,9,5,5,1,6,1,5};
bool judge(){
if(strlen(a+1)>20) return true;
if(strlen(a+1)<20) return false;
for(int i=1;i<=20;i++){
// printf("i=%d\n",i);
if(a[i]-'0'>pd[i]) return true;
if(a[i]-'0'<pd[i]) return false;
}
return false;
}
int main(){
scanf("%d",&t);
scanf(" %s",a+1);
if(a[1]=='u') flag=1,scanf(" %s",a+1);
else flag=0;
int l=strlen(a+1);
for(int i=1;i<=l;i++) s[i]=a[i];
while(t--){
num=0,jd=0;
ull now=1;
if(flag==0){
if(s[4]=='8') mx=int8;
else if(s[4]=='1') mx=int16;
else if(s[4]=='3') mx=int32;
else if(s[4]=='6') mx=int64;
}
else{
if(s[4]=='8') mx=uint8;
else if(s[4]=='1') mx=uint16;
else if(s[4]=='3') mx=uint32;
else if(s[4]=='6') mx=uint64;
}
// printf("mx=%lld\n",mx);
while(scanf(" %s",a+1)!=EOF){
// printf("a=%s\n",a+1);@[toc]
if(a[1]=='i'||a[1]=='u'){
if(jd==0) printf("never\n");
if(a[1]=='u') flag=1,scanf(" %s",a+1);
else flag=0;
int l=strlen(a+1);
for(int i=1;i<=l;i++) s[i]=a[i];
break;
}
if(jd) continue;
num++;
if(judge()){
jd=1;printf("%d\n",num);continue;
}
ull x;
sscanf(a+1,"%lld",&x);
// printf("a=%s x=%lld now=%lld\n",a+1,x,now);
if(x>mx/now) jd=1,printf("%d\n",num);
else now*=x;
// printf("okk:x=%lld now=%lld\n",x,now);
}
}
if(jd==0) printf("never\n");
return 0;
}
/*
unsigned int64 18446744073709551615
*/
I:
点击查看代码
#include<bits/stdc++.h>
using namespace std;
string fn,now;
inline bool dfs(const string &path){
if(!(cin>>now)) return false;
string nxt=!path.empty() ? path+"\\"+now : now;
if(now.find_first_of('.')!=string :: npos){
if(now==fn) cout<<nxt<<'\n';
}else{
int num;
cin>>num;
while(num--) dfs(nxt);
}
return true;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>fn;
while(dfs(""));
return 0;
}
J:
点击查看代码
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int t;
bool wqzfc(string s1,string s2){
if(s1.size()&1 && s1!=s2){
return false;
}
if(s1==s2){
return true;
}
int nb=s1.size()>>1;
if((wqzfc(s1.substr(nb),s2.substr(0,nb)) && wqzfc(s1.substr(0,nb),s2.substr(nb))) ||
(wqzfc(s1.substr(nb),s2.substr(nb)) && wqzfc(s1.substr(0,nb),s2.substr(0,nb)))
){
return true;
}
else return false;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>t;
while(t--){
cin>>s1>>s2;
if(wqzfc(s1,s2)){
cout<<"YES\n";
}
else {
cout<<"NO\n";
}
}
return 0;
}