2012-2013 ACM-ICPC, NEERC, Central Subregional Contest C Sequence (打表)
2015-09-03 18:20
459 查看
打个表找找规律,到24445的时候乘2以后产生了0出现循环。
一般地,判断循环节是否存在可以用Floyd判圈算法。
一般地,判断循环节是否存在可以用Floyd判圈算法。
#include<bits/stdc++.h> using namespace std; typedef long long ll; int ans[] { -1 ,1 ,2 ,4 ,8 ,16 ,23 ,46 ,29 ,58 ,116 ,223 ,446 ,289 ,578 ,1156 ,1223 ,2446 ,2489 ,4789 ,5789 ,11578 ,12356 ,12247 ,24449 }; int b[] { 48889 ,77789 ,155578 ,111356 ,122227 ,244445 }; int main() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); int n ; scanf("%d",&n); printf("%d\n",n>=25?b[(n-25)%6]:ans ); return 0; }
相关文章推荐
- 一篇讲得非常好的build模式的解释文章
- maven -- 问题解决(二)解决“Could not calculate build plan”问题
- STL vector, deque, list对比
- [刷题]Implement Queue by Two Stacks
- 九度OJ 题目1119:Integer Inquiry
- 让UITextView文字垂直居中
- UITextFiledView页面之间的相互传值
- Android UI设计(引导界面):ViewPager之三PagerTabStrip与PagerTitleStrip添加标题栏的区别
- jquey.fullpage详解
- UINavigaionController中的传值(协议)
- Android UI设计——ViewPage的无限循环(五)
- Arduino LM35温度检测
- RYU的GUI安装
- 黑马程序员—————Java基础--------GUI
- Android UI设计——ViewPage中自定义标题栏(四)
- UI触屏的操作初识
- 使用eventqueue.invokelater()好处、原因
- UIAlertView
- ios开发 UI阶段第八周
- UINavigationController