5 条题解
-
1
/* 因为回文串正序反序都一样,所以用字符串模拟数字,一个赋值为正序,一个为反序,再比较异同就可以了 *///2026 5 14 17:47 #include <iostream> #include <algorithm> #include <iomanip> #include <cstdio> #include <string> #include <ios> #pragma GCC optimize("Ofast") #define by #define code #define AC 0 #define 一只傻兔 using std::ios; using std::cin; using std::cout; using std::sort; using std::string; using std::freopen; code by 一只傻兔 string 一只傻兔の代码 = {"C++17"}; short N; string Number; bool Compare(int a, int b) { return a > b; } signed main(void) { //freopen("AC.in", "r", stdin); //freopen("AC.out", "w", stdout); ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); cin >> N; while(N--) { cin >> Number; sort(Number.begin(), Number.end(), Compare); cout << Number << ' '; sort(Number.begin(), Number.end()); while(Number[0] == '0' && Number.size() > 1) { Number.erase(Number.begin()); } cout << Number << '\n'; } return AC; }
信息
- ID
- 203
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 8
- 标签
- (无)
- 递交数
- 1435
- 已通过
- 221
- 上传者