2 条题解
-
3莫言 (slz莫言) LV 9 @ 2024-11-25 21:18:58
下面还有简化版
#include <bits/stdc++.h> #define LL long long using namespace std; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; char c [20]; bool flag; int cnt , sum; stack < int > q1; queue < int > q2; int a; int main() { cin >> c; for (int i = 0; i < strlen (c); i++) { if (c [i] == '0') { if (flag) { cnt++; } } else { while ( cnt != 0 ) { --cnt; q1.push (a); q2.push (a); } flag = 1; q1.push ( (int) ( c [i] - '0' )); q2.push ( (int) ( c [i] - '0' )); }// } while ( !q1.empty()) { //int a = q1.front if ( q1.top() == q2.front() ) { q1.pop(); q2.pop(); } else { cout << "No"; return 0; } } cout << "Yes"; return 0; }
#include <bits/stdc++.h> using namespace std; #define LL long long const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; string s; int main() { cin >> s; while( s[s.size() - 1] == '0' && s.size() > 1) s.erase(s.size() - 1); string s1 = s; reverse(s.begin() , s.end()); if( s == s1) cout << "Yes"; else cout << "No"; return 0; }
-
-12024-12-1 18:31:19@
最简代码
#include<bits/stdc++.h> using namespace std; const int N=1e4+10; string s; int main(){ cin>>s; while(s[s.size()-1]=='0'&&s.size()>1)s.erase(s.size()-1); string t=s; reverse(s.begin(),s.end()); if(s==t)cout<<"Yes"; else cout<<"No"; return 0; }
- 1
信息
- ID
- 3222
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- 递交数
- 134
- 已通过
- 27
- 上传者