题解
2025-06-27 20:21:27
发布于:浙江
26阅读
0回复
0点赞
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
string s;
cin >> s;
int n = s.size();
int total = 0;
for (char c : s) {
total += c - 'a' + 1;
}
if (n == 1) {
cout << "D " << total << endl;
continue;
}
int acScore, dScore;
if (n % 2 == 0) {
acScore = total;
dScore = 0;
} else {
int frontSum = total - (s.back() - 'a' + 1);
int backSum = total - (s[0] - 'a' + 1);
acScore = max(frontSum, backSum);
dScore = total - acScore;
}
int diff = acScore - dScore;
cout << (acScore > dScore ? "AC " : "D ") << diff << endl;
}
return 0;
}
这里空空如也
有帮助,赞一个