4 条题解

  • 1
    @ 2025-12-4 23:37:35
    #include <iostream>
    #include <algorithm>
    #include <string>
    using namespace std;
    
    int main()
    {
        string str1;
        getline(cin, str1);
        string str2 = str1;
        reverse(str2.begin(),str2.end());
        if(str1.size() == 0) cout << "YES";
        else if(str1.size() % 2 == 0)
        {
            if(str1 == str2) cout << "YES";
            else cout << "NO";
        }
        else cout << "NO";
        return 0;
    }
    • 1
      @ 2025-10-5 15:46:56
      #include <iostream>
      #include <string>
      using namespace std;
      int main() 
      {
          string str;
          getline(cin, str);
      
          if (str.length() % 2 == 1)
          {
              cout << "NO" << endl;
              return 0;
          }
          
          int left = 0;
          int right = str.length() - 1;
      
          while (left < right) 
          {
              if (str[left] != str[right]) 
              {
                  cout << "NO" << endl;
                  return 0;
              }
              left++;
              right--;
          }
          cout << "YES" << endl;
          return 0;
      }
      
      • 1
        @ 2025-10-2 21:55:05

        这一题的陷阱在于出题人的超绝语文功底。

        题目翻译:给你一个字符串,要求其长度为偶数(1:1),并且是回文串。

        你莫名其妙说一个1:1,谁知道你是什么意思?

        #include<string.h>
        #include<stdlib.h> 
        #include<math.h>
        
        int main(){
        	char a[101];
        	int i;
        	int shi=1;
        	fgets(a,sizeof(a),stdin);
        	int len;
        	len=strlen(a);
        	if(len>0&&a[len-1]=='\n'){
        		a[len-1]='\0';
        		len--;
        	}
        	if(len==0){
        		printf("YES");
        		return 0;
        	}
        	if(len%2!=0){
        		printf("NO");
        		return 0;
        	}
        
        	for(i=0;i<len/2;i++){
        		if(a[i]!=a[len-1-i]){
        			shi=0;
        			break;
        		}
        	}
        	if(shi==0){
        		printf("NO");
        	}
        	else if(shi==1){
        		printf("YES");
        	}
            return 0;
        }
        
        • 0
          @ 2024-11-10 11:12:36

          #include<bits/stdc++.h> using namespace std; int main() { string s;

          cin>>s;
          
          int mid=s.size()/2-1;
          
          int flag=1;
          
          for(int l=0,r=s.size()-1; l<=mid; l++,r--)
          {
              if(s[l]!=s[r])
                  flag=0;
          }
          
          if(s.size()%2==1)
          	flag=0;
          
          if(flag==1)
              cout<<"YES";
          else
              cout<<"NO";
          
          return 0;
          

          }

          偶数才算1:1!!!

          • 1

          信息

          ID
          37
          时间
          1000ms
          内存
          512MiB
          难度
          2
          标签
          递交数
          1166
          已通过
          139
          上传者