题干:

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 s, containing only digits. He needs to find a string that

  • represents a lucky number without leading zeroes,
  • is not empty,
  • is contained in s 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.

Input

The single line contains a non-empty string s whose length can range from 1 to 50, inclusive. The string only contains digits. The string can contain leading zeroes.

Output

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

Examples

Input

047

Output

4

Input

16

Output

-1

Input

472747

Output

7

Note

The lexicographical comparison of strings is performed by the < operator in the modern programming languages. String x is lexicographically less than string yeither if x is a prefix of y, or exists such i (1 ≤ i ≤ min(|x|, |y|)), that xi < yiand for any j (1 ≤ j < ixj = yj. Here |a| denotes the length of string a.

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

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

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

题目大意:

给你一个可能有前导零的数字,让你找一个子串,满足三个条件,其中第三个是,包含最大数量的幸运数字,也就是说,4和7谁多 就要包含谁,又因为是字典序最小的,所以就是那个数字本身喽。

解题报告:

读懂题目就好了,另外就是注意ifelse啥的之类的别落下情况。先排除-1 的情况,然后再else其他的情况。

就是题目不太好懂。

AC代码:

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAX = 1e5 +5;
int main()
{string s;cin>>s;ll len = s.length(),n4=0,n7=0;for(int i = 0; i<len; i++) {if(s[i] == '4') n4++;if(s[i] == '7') n7++;}if(n4 == 0 && n7 == 0) puts("-1");else {if(n7 > n4) puts("7");else puts("4");}return 0 ;} 

【CodeForces - 122B 】Lucky Substring (字符串,水题)相关推荐

  1. codeforces 133A HQ9+(字符串水题)

    A. HQ9+ 点击打开题目 time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...

  2. Coderforces 字符串水题合集

    今天我们聊聊 Coderforces 字符串水题合集. 字符串就是string. 这是string的百度翻译,我们要谈的是画框的.↓ string是C++.java.VB等编程语言中的字符串,字符串是 ...

  3. 1001 字符串“水”题(二进制,map,哈希)

    1001: 字符串"水"题 时间限制: 1 Sec  内存限制: 128 MB 提交: 210  解决: 39 [提交][状态][讨论版] 题目描述 给出一个长度为 n 的字符串( ...

  4. 字符串水题——相对分子质量

    问题 G: 相对分子质量 时间限制: 1 Sec  内存限制: 32 MB 提交: 5  解决: 5 [提交][状态][讨论版] 题目描述 小明最近迷上了化学,几乎天天在实验室做实验,但是很多实验生成 ...

  5. Codeforces 864 A Fair Game 水题

    题目链接: http://codeforces.com/problemset/problem/864/A 题目描述: 看不是是不是一串数中只有两种数且这两种数字的数量是相同的 解题思路: 水题, 水过 ...

  6. CodeForces - 1141D Colored Boots(暴力+水题)

    题目链接:点击查看 题目大意:给出两个字符串s和t,两个字符串中相同的字母可以匹配,问号可以和任意字符匹配,现在问两个字符串最多能匹配多少个字符,并给出匹配的下标 题目分析:挺好玩的一道水题,大体思路 ...

  7. 【CodeForces - 569B】Inventory (水题)

    题干: Companies always have a lot of equipment, furniture and other things. All of them should be trac ...

  8. codeforces 702A A. Maximum Increase(水题)

    题目链接: A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input sta ...

  9. Codeforces Round #309 (Div. 2) A. Kyoya and Photobooks 字符串水题

    A. Kyoya and Photobooks Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  10. codeforces 112APetya and Strings(字符串水题)

    A. Petya and Strings 点击打开题目 time limit per test 2 seconds memory limit per test 256 megabytes input ...

最新文章

  1. [改善Java代码]优先使用整型池
  2. Nginx动态、静态分离,Nginx配置中做适配
  3. 全球及中国真空管太阳能集热器行业竞争状况及投资策略研究报告2021年版
  4. Java 8 Stream 使用
  5. impdp导入dmp文件
  6. 142_Power BI之同比预测
  7. 计算机应用技术三级学科,三个计算机专业的区别是什么?
  8. NC6.3 变更销售合同维护模板后单据追溯查询提示权限问题的解释
  9. 2013海淀驾校学车日记
  10. Processing学习笔记
  11. ORACLE莫明其妙出错!
  12. 深入理解MySQL核心技术
  13. 一文理解CPU进行简单加法(计算机组成原理5.1CPU的功能和基本结构)
  14. 基于单片机的篮球计数器设计
  15. 《华尔街》观后笔记8——明暗创新
  16. 那个叫“中国移动”的精神病人就要被治愈了
  17. SUSCTF 2022圆满落幕,SU战队夺冠
  18. 再生龙制作u盘启动linux,再生龙制作U盘启动盘教程 | 楚盟博客
  19. ISTP(CPCI)会议论文出版都经常有那些刊物?
  20. git tag 和 branch 的区别以及使用场景

热门文章

  1. [Leedcode][JAVA][第67题][二进制求和][位运算][字符串]
  2. linux系统时间函数,Linux时间时区详解与常用时间函数
  3. 不用电脑怎么设置苹果铃声_苹果手机怎么设置铃声?完整教程分享
  4. python爬虫反爬对抗_python爬虫反反爬,你几乎可以横扫大部分 css 字体加密的网站...
  5. maya怎么贴膜_maya怎么渲染成白膜?
  6. java 页面输出一个页面_java学习之:一个完整页面输出信息的过程(以输出Doctor表中信息为例)...
  7. java httpclient 关闭_【Java系列007】HttpClient调用:你考虑过关闭连接、并发了吗?...
  8. VC嵌入python时debug版lib下载
  9. modf函数C语言,C / C ++中的modf()
  10. 简单网络聊天程序java_基于Java实现hello/hi简单网络聊天程序