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
目录
相关文章
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
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
89 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
71 0
The Preliminary Contest for ICPC China Nanchang National Invitational M题 Subsequence
The Preliminary Contest for ICPC China Nanchang National Invitational M题 Subsequence
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
67 0
|
机器学习/深度学习 BI
2020-2021 ACM-ICPC, Asia Seoul Regional Contest L. Two Buildings (决策单调性 分治)
2020-2021 ACM-ICPC, Asia Seoul Regional Contest L. Two Buildings (决策单调性 分治)
131 0
2020-2021 ACM-ICPC, Asia Seoul Regional Contest L. Two Buildings (决策单调性 分治)
2020 ICPC Asia Taipei-Hsinchu Site Programming Contest H. Optimization for UltraNet (二分+最小生成树+算贡献)
2020 ICPC Asia Taipei-Hsinchu Site Programming Contest H. Optimization for UltraNet (二分+最小生成树+算贡献)
125 0
|
移动开发 前端开发
ICPC Latin American Regional 2017-Imperial roads(LCA)
题目大意: 给出n个点,m条边的一个图,q个询问, 每次询问给出两个点u,v,问包含u-v这条边的最小生成树是多少 这道题比较板 首先求一下这个图的最小生成树对于这n个点,最小生成树一定是n-1条边,如果说再加上一条边,一定会构成一个环。 我们把生成的这个最小生成树看作是一个以1为根节点的最小生成树。 所以说在下面的q个询问中,如果说这条边用到了最小生成树中(这条边是最小生成树上的边),那么直接输出当前最小生成树的代价就好;如果说当前这条边没有出现在最小生成树当中,那么最小生成树的权值val加上这条边之后就构成了一个环,求出这两个点所在的环内的最大边权,并将这个边权减去,就是最终结果
115 0
ICPC Latin American Regional 2017-Imperial roads(LCA)