解决约瑟夫环问题
摘要:1. 问题描述 一个旅行社要冲n个旅客中选出一名旅客,为他提供免费的环球旅行服务。旅行社安排这些旅客围城一个圈,从帽子中取出一张纸条,用上面写的正整数m(m> n; cout > m; for(int i=1 ; i<n ; i++) s = (s+m)%i; ...
阅读全文
posted @
2015-03-14 21:45
HanEichy
阅读(387)
推荐(0)
LeetCode题目:Majority Element
摘要:这同样也是一道LeetCode Online Judge上面的题目,属于easy级别,原题如下:题目 Given an array of sizen, find the majority element. The majority element is the element that app...
阅读全文
posted @
2015-01-29 20:53
HanEichy
阅读(200)
推荐(0)
LeetCode题目:Factorial Trailing Zeroes(析因,求尾随个0个数)
摘要:Given an integern, return the number of trailing zeroes inn! 这是LeetCode Online Judge上的一个原题:给定一个n,求n!中,末尾0的个数。思路n!中0的个数,可以将n!表示成 n!=m*10k,其中k就是题目要求的...
阅读全文
posted @
2015-01-28 22:16
HanEichy
阅读(282)
推荐(0)