摘要: 分析:2013!的六进制表示法尾部包含的0的个数意味着其因数分解中包含6的个数; 比如6!=6*5*4*3*2*1=(720)10进制=(3200)6进制,可见尾部包含2个0;深入分析:6=2*3,所以凡是因数分解中包含6的数一定能将6进一步分解为2和3,且2、3为质因数;所以,可以遍历1-2013的每个数N,求得所有N的质因数分解中包含的3的个数count,然后累加所有count即为最后结果。代码如下:int count_three(int N){ int count=0; while(N%3==0) { count++; N /= 3; ... 阅读全文
posted @ 2013-04-28 22:28 xiaowenchao 阅读(238) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std;using namespace stdext;//acronym : LNSpair longest_norepeat_substring( string& str ){ hash_map char_index;//save the character and last postion it appears size_t currentStart = 0;//start position of the LNS size_t repeated_postion = 0;//the last pos 阅读全文
posted @ 2013-04-28 22:05 xiaowenchao 阅读(194) 评论(0) 推荐(0) 编辑