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
目录
相关文章
|
开发框架 前端开发 .NET
七天.NET 8操作SQLite入门到实战 - (1)第七天BootstrapBlazor UI组件库引入
七天.NET 8操作SQLite入门到实战 - (1)第七天BootstrapBlazor UI组件库引入
329 0
无线局域网
WLAN(Wireless Local Area Network)指应用无线通信技术与网络技术,将计算机设备互联起来,构成可以互相通信、实现资源共享的网络体系。WLAN利用射频技术,使用电磁波,通过无线的方式连接,从而使网络的搭建和终端的接入更加灵活。
710 1
|
数据采集 NoSQL 数据管理
数据治理体系建设
随着信息化的不断发展,数据的数量和质量都呈现了爆发式的增长,数据已经成为核心资源。数据治理是银行实现数字化转型、提升核心竞争力的重要手段,也是银行信息化建设的重要组成部分。
|
Ubuntu Shell API
Ubuntu 64系统编译android arm64-v8a 的openssl静态库libssl.a和libcrypto.a
Ubuntu 64系统编译android arm64-v8a 的openssl静态库libssl.a和libcrypto.a
|
JSON JavaScript 前端开发
js省市区三级联动
js省市区三级联动
315 1
|
存储 缓存 NoSQL
Redis宕机了,数据该怎么办?
本文带你彻底理解Redis中数据持久化问题,拒绝宕机之后的无助!
Redis宕机了,数据该怎么办?
|
编解码 人工智能 对象存储
EAS
EAS
630 3
|
前端开发 JavaScript
【Web 前端】 js中call、apply、bind有什么区别?
【4月更文挑战第22天】【Web 前端】 js中call、apply、bind有什么区别?
【Web 前端】 js中call、apply、bind有什么区别?
|
前端开发
【UI】 elementui的dialog弹窗打开时CSS的BUG | 滚动条消失bug
【UI】 elementui的dialog弹窗打开时CSS的BUG | 滚动条消失bug
705 0
|
存储 JavaScript
Vue中如何在组件销毁时清理定时器?
Vue中如何在组件销毁时清理定时器?
602 1