hdu 5455 Fang Fang(2015 ACM/ICPC Asia Regional Shenyang Online)

简介:

点击打开链接

Fang Fang

Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 531    Accepted Submission(s): 232


Problem Description
Fang Fang says she wants to be remembered.
I promise her. We define the sequence  F of strings.
F0 = f",
F1 = ff",
F2 = cff",
Fn = Fn1 + f", for n > 2
Write down a serenade as a lowercase string  S in a circle, in a loop that never ends.
Spell the serenade using the minimum number of strings in  F, or nothing could be done but put her away in cold wilderness.
 

Input
An positive integer  T, indicating there are  T test cases.
Following are  T lines, each line contains an string  S as introduced above.
The total length of strings for all test cases would not be larger than  106.
 

Output
The output contains exactly  T lines.
For each test case, if one can not spell the serenade by using the strings in  F, output  1. Otherwise, output the minimum number of strings in  F to split  Saccording to aforementioned rules. Repetitive strings should be counted repeatedly.
 

Sample Input
 
 
8 ffcfffcffcff cffcfff cffcff cffcf ffffcffcfff cffcfffcffffcfffff cff cffc
 

Sample Output
 
 
Case #1: 3 Case #2: 2 Case #3: 2 Case #4: -1 Case #5: 2 Case #6: 4 Case #7: 1 Case #8: -1
Hint
Shift the string in the
目录
打赏
0
0
0
0
2
分享
相关文章
2021 ICPC Asia Regionals Online Contest (II) Problem G. Limit
2021 ICPC Asia Regionals Online Contest (II) Problem G. Limit
The Preliminary Contest for ICPC China Nanchang National Invitational H题 Coloring Game
The Preliminary Contest for ICPC China Nanchang National Invitational H题 Coloring Game
106 0
The Preliminary Contest for ICPC China Nanchang National Invitational A题 PERFECT NUMBER PROBLEM
The Preliminary Contest for ICPC China Nanchang National Invitational A题 PERFECT NUMBER PROBLEM
86 0
The Preliminary Contest for ICPC China Nanchang National Invitational J题 Distance on the tree
The Preliminary Contest for ICPC China Nanchang National Invitational J题 Distance on the tree
105 0
The Preliminary Contest for ICPC China Nanchang National Invitational M题 Subsequence
The Preliminary Contest for ICPC China Nanchang National Invitational M题 Subsequence
94 0
2020-2021 ACM-ICPC, Asia Seoul Regional Contest L. Two Buildings (决策单调性 分治)
2020-2021 ACM-ICPC, Asia Seoul Regional Contest L. Two Buildings (决策单调性 分治)
153 0
2020-2021 ACM-ICPC, Asia Seoul Regional Contest L. Two Buildings (决策单调性 分治)
2012 ACM/ICPC Asia Regional Changchun Online-LianLianKan
题意:类似于我们玩的连连看,从上往下,6个水果内如果有相同的2个水果则可以消去,直至水果被消完,输出1,或是找不到可以消去的水果,输出0。
130 0
2012 ACM/ICPC Asia Regional Tianjin Online-Faulty Odometer
题意:有个特殊汽车的行程表,每逢数字3和8会跳过直接到4和9,给你一个行程表的示数,求汽车实际走的路程。
149 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等