日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

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

發(fā)布時(shí)間:2023/12/10 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【CodeForces - 122B 】Lucky Substring (字符串,水题) 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

題干:

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?<?i)?xj?=?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".

題目大意:

? ?給你一個(gè)可能有前導(dǎo)零的數(shù)字,讓你找一個(gè)子串,滿足三個(gè)條件,其中第三個(gè)是,包含最大數(shù)量的幸運(yùn)數(shù)字,也就是說(shuō),4和7誰(shuí)多 就要包含誰(shuí),又因?yàn)槭亲值湫蜃钚〉?#xff0c;所以就是那個(gè)數(shù)字本身嘍。

解題報(bào)告:

? ? 讀懂題目就好了,另外就是注意ifelse啥的之類(lèi)的別落下情況。先排除-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 ;}

?

總結(jié)

以上是生活随笔為你收集整理的【CodeForces - 122B 】Lucky Substring (字符串,水题)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。