CF122B.Lucky Substring

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

One day Petya was delivered a string ss , containing only digits. He needs to find a string that

  • represents a lucky number without leading zeroes,
  • is not empty,
  • is contained in ss as a substring the maximum number of times.

Among all the strings for which the three conditions given above are fulfilled, Petya only needs the lexicographically minimum one. Find this string for Petya.

输入格式

The single line contains a non-empty string ss whose length can range from 11 to 5050 , inclusive. The string only contains digits. The string can contain leading zeroes.

输出格式

In the only line print the answer to Petya's problem. If the sought string does not exist, print "-1" (without quotes).

输入输出样例

  • 输入#1

    047
    

    输出#1

    4
    
  • 输入#2

    16
    

    输出#2

    -1
    
  • 输入#3

    472747
    

    输出#3

    7
    

说明/提示

The lexicographical comparison of strings is performed by the < operator in the modern programming languages. String xx is lexicographically less than string yy either if xx is a prefix of yy , or exists such ii ( 1<=i<=min(x,y)1<=i<=min(|x|,|y|) ), that x_{i}<y_{i} and for any jj ( 1<=j<i ) xj=yjx_{j}=y_{j} . Here a|a| denotes the length of string aa .

In the first sample three conditions are fulfilled for strings "4", "7" and "47". The lexicographically minimum one is "4".

In the second sample ss has no substrings which are lucky numbers.

In the third sample the three conditions are only fulfilled for string "7".

首页