#C9639. Reverse String if Not Palindrome
Reverse String if Not Palindrome
Reverse String if Not Palindrome
You are given a string (s). Your task is to determine whether (s) is a palindrome. A palindrome is defined as a string that reads the same backwards as forwards. If (s) is a palindrome, output the original string. Otherwise, output the reversed string. Note that the comparison is case sensitive (e.g., Madam
is not considered the same as madam
).
Mathematically, a string (s) is a palindrome if and only if (s = s^{\text{rev}}), where (s^{\text{rev}}) denotes the reverse of (s).
inputFormat
The input consists of a single line containing the string (s). The string may contain spaces, punctuation, and is case sensitive.
outputFormat
Output a single line containing the result. If the string is a palindrome, print the original string; otherwise, print the reversed string.## sample
racecar
racecar