AT2153 [ARC064B] An Ordinary Game 题解
an 题解 Game
2023-06-13 09:12:17 时间
题目链接 : AT2153 [ARC064B] An Ordinary Game
一道大水题
这题有个挺重要的点,需要注意 :
- Remove one of the characters in s , excluding both ends.
- 删除 s 中的一个字符,不包括两端。
通过观察可发现,如果输入的字符串长度是偶数,且 s 两端是相等的字符串,则 ans = "First",否则的话,ans = "Second";当输入的字符串长度是奇数,且 s 两端是相等的字符串,则 ans = "First",否则的话,ans = "Second"。
判断 s 两端是相等时,可以用 s.front() == s.back(),具体请 bdfs(百度优先搜索)。
Code:
#include <iostream> // 不要忘记 cstring 头文件
#include <cstring>
int main()
{
std::string ans; // ans 记录答案
std::string s;
std::cin >> s;
if (s.length() % 2) // len 为奇数时
{
ans = (s.front() == s.back()) ? "Second" : "First";
}
else // len 为偶数时
{
ans = (s.front() == s.back()) ? "First" : "Second";
} // 先判断奇偶, 再判断首尾
std::cout << ans << std::endl;
return 0;
}
相关文章
- 【错误记录】Android Studio 编译报错 ( Module was compiled with an incompatible version of Kotlin. ) 2
- ORA-01757: Must specify an object number ORACLE 报错 故障修复 远程处理
- ORA-19294: XQST0059: It is a static error if an implementation is unable to process a schema or module import by finding a schema or module with the specified target namespace ORACLE 报错 故障修复 远程处理
- ORA-22806: not an object or REF ORACLE 报错 故障修复 远程处理
- ORA-26869: must attach to an XStream inbound server before executing string function ORACLE 报错 故障修复 远程处理
- ORA-26927: altering an outbound server with a remote capture is not allowed ORACLE 报错 故障修复 远程处理
- ORA-30155: An I/O Error occured during an OCIFile function call ORACLE 报错 故障修复 远程处理
- ORA-32307: must use FROM ONLY clause when referencing an object table ORACLE 报错 故障修复 远程处理
- ORA-54026: Real column cannot have an expression ORACLE 报错 故障修复 远程处理
- ORA-64125: XMLIndex: failure during the resetting of an event ORACLE 报错 故障修复 远程处理
- ORA-06536: IN bind variable bound to an OUT position ORACLE 报错 故障修复 远程处理
- ORA-18117: XUDY0018 – External not updating function returns an updated value ORACLE 报错 故障修复 远程处理