公式

A - Strong Word 解説 by en_translator


It is sufficient to compare the first and last characters of \(S\).

Different languages have different ways to obtain the first and last character; also, multiple ways may be possible in one language. The following is sample code in C++ and Python.

#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    if (S.front() == S.back()) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
S = input()
if S[0] == S[-1]:
    print("Yes")
else:
    print("No")

投稿日時:
最終更新: