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
目录
相关文章
|
6月前
|
人工智能 Java
hdu 1165 Eddy's research II
hdu 1165 Eddy's research II
36 0
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
88 0
The Preliminary Contest for ICPC China Nanchang National Invitational M题 Subsequence
The Preliminary Contest for ICPC China Nanchang National Invitational M题 Subsequence
75 0
|
机器学习/深度学习 人工智能
The Preliminary Contest for ICPC China Nanchang National Invitational K题 MORE XOR
The Preliminary Contest for ICPC China Nanchang National Invitational K题 MORE XOR
72 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
70 0
|
机器学习/深度学习 人工智能
The Preliminary Contest for ICPC China Nanchang National Invitational I题 Max answer
The Preliminary Contest for ICPC China Nanchang National Invitational I题 Max answer
94 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
93 0
|
机器学习/深度学习 BI
2020-2021 ACM-ICPC, Asia Seoul Regional Contest L. Two Buildings (决策单调性 分治)
2020-2021 ACM-ICPC, Asia Seoul Regional Contest L. Two Buildings (决策单调性 分治)
132 0
2020-2021 ACM-ICPC, Asia Seoul Regional Contest L. Two Buildings (决策单调性 分治)