解决方案:

int _tmain(int argc,_TCHAR* argv[])
{
size_t fib[] = {1,2,3,5,8,13,21,34};
string str,tempstr;
cin >> str;
tempstr = str;
auto it = unique(tempstr.begin(),tempstr.end());
tempstr.erase(it,tempstr.end()); // 去重(已假定是有序的,如果无序则先排序) for (auto itstr = str.begin(); itstr != str.end();) // 遍历输入数据
{
string s(itstr,str.end());
for (int i = 0; i < 8;i++)
{
if (fib[i] <= tempstr.size()) // 符合FIB的不同字符有多少,则输出多少次
{
auto singlechar = tempstr[i];
auto findchar = s.find(singlechar);
for (auto itchar = s.begin() + findchar; itchar != s.end()&&*itchar == singlechar;itchar++)
{ // 输出,相同字符连续输出
if (*s.begin() == singlechar) // 每次去掉第一个相同的字符
{
itstr++;
}
cout << string(s.begin(),itchar+1) << endl;
}
}
else
{
tempstr.erase(tempstr.begin()); // 字典输出需要
break;
}
}
} return 0;
}

讨论贴:

http://bbs.csdn.net/topics/391023839

后面碰见有关斐波那契数列的题目非常多,这块还有一个求期望的:

http://bbs.csdn.net/topics/391822110

正确答案:

http://blog.csdn.net/u010476094/article/details/48110405

这他妈的也太难算了吧

最新文章

  1. CSS3 Animation Cheat Sheet:实用的 CSS3 动画库
  2. C#程序猿电脑重装记录
  3. Ezchip Tilera Tile-Mx100: Der 100-ARM-Netzwerkprozessor
  4. Enum:Backward Digit Sums(POJ 3187)
  5. Leetcode: Alien Dictionary &amp;&amp; Summary: Topological Sort
  6. Codeforces 626D Jerry&#39;s Protest 「数学组合」「数学概率」
  7. 如何解决加载动态链接库DLL失败,返回0,GetLastError返回错误码126
  8. 如何使用 OneAPM 监控微软 Azure Cloud Service ?
  9. 回顾Ado.Net
  10. Mysql 冷备份批处理
  11. POJ_2104_Kth_(主席树)
  12. bellman_ford寻找平均权值最小的回路
  13. 老帖收藏,留供参考:SpringMvc2.5+Mybatis3.2.7
  14. Apache shiro集群实现 (七)分布式集群系统下---cache共享
  15. springboot之启动原理解析
  16. 报错【org.springframework.validation.BeanPropertyBindingResult】
  17. 微信小程序错误码参考大全
  18. hibernate框架学习第三天:对象状态、一级缓存、快照等
  19. hibernate的Could not execute JDBC batch update错误原因及处理
  20. shell脚本--cut命令与awk简单使用

热门文章

  1. 【BZOJ1016】【JSOI2008】最小生成树计数
  2. 【USACO】奶牛抗议 树状数组+dp
  3. hdu 5645 DZY Loves Balls
  4. C语言预备作业
  5. Linux常用命令大全(归类)
  6. Linux学习之CentOS(四)----Linux文件属性、所有者、群组、其他组及文件权限操作简要总结
  7. 自定义shell终端提示符及颜色即修改 PS1文件 (以Centos为例)
  8. webstorm 设置uglify 压缩js文件
  9. 借助Bodymovin播放svg动画
  10. Web压力测试和手机App测试