A. LLPS
来源:互联网 发布:怎么推广淘宝客 编辑:程序博客网 时间:2024/06/01 09:14
This problem's actual name, "Lexicographically Largest Palindromic Subsequence" is too long to fit into the page headline.
You are given string s consisting of lowercase English letters only. Find its lexicographically largest palindromic subsequence.
We'll call a non-empty string s[p1p2... pk] = sp1sp2... spk (1 ≤ p1 < p2 < ... < pk ≤ |s|) a subsequence of string s = s1s2... s|s|, where |s|is the length of string s. For example, strings "abcb", "b" and "abacaba" are subsequences of string "abacaba".
String x = x1x2... x|x| is lexicographically larger than string y = y1y2... y|y| if either |x| > |y| and x1 = y1, x2 = y2, ..., x|y| = y|y|, or there exists such number r (r < |x|, r < |y|) that x1 = y1, x2 = y2, ..., xr = yr and xr + 1 > yr + 1. Characters in the strings are compared according to their ASCII codes. For example, string "ranger" is lexicographically larger than string "racecar" and string "poster" is lexicographically larger than string "post".
String s = s1s2... s|s| is a palindrome if it matches string rev(s) = s|s|s|s| - 1... s1. In other words, a string is a palindrome if it reads the same way from left to right and from right to left. For example, palindromic strings are "racecar", "refer" and "z".
The only input line contains a non-empty string s consisting of lowercase English letters only. Its length does not exceed 10.
Print the lexicographically largest palindromic subsequence of string s.
radar
rr
bowwowwow
wwwww
codeforces
s
mississipp
ssss
Among all distinct subsequences of string "radar" the following ones are palindromes: "a", "d", "r", "aa", "rr", "ada", "rar", "rdr", "raar" and "radar". The lexicographically largest of them is "rr".
解题说明:此题就是统计出一个字符串中最大的字母是什么,个数有几个,这就是该字符串最大的字串
#include <stdio.h>int main () {char m, c;int cnt=0;m='a';while (scanf("%c", &c)!=EOF) {if (c>m){m = c;cnt = 0;}if (c==m){cnt++;}}c=0;while (c++!=cnt){printf("%c",m);}return 0;}
- A. LLPS
- CodeForces - 202A LLPS
- Codeforces Round #127 (Div. 2) A. LLPS
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- a
- A
- A*
- MySQL的REGEXP 和 like 在匹配上的区别
- eclipse 常用快捷键
- 香港拼音--汉字对照表
- windows和linux下Select()函数的区别
- iOS中操作CoreData框架设计
- A. LLPS
- JBOSS 使用集群单点登录SSO
- java反射机制详解
- 遇见,很美
- POJ 2185 Milking Grid(最小覆盖子矩阵面积KMP)
- Javascript学习笔记(四)
- hdu 1874 畅通工程续(最短路)
- Visual Studio 2012 编译C++显示cl命令
- java实现深度优先遍历