Differences between revisions 3 and 5 (spanning 2 versions)
Revision 3 as of 2006-01-31 14:45:13
Size: 1181
Editor: 143
Comment:
Revision 5 as of 2006-01-31 17:08:57
Size: 688
Editor: 211
Comment:
Deletions are marked like this. Additions are marked like this.
Line 32: Line 32:
속도를 재서 다른 분들과 비교해 봤습니다. input이 1 999999 일때.

||작성자 ||||<style="TEXT-ALIGN: center">걸린시간 ||||<style="TEXT-ALIGN: center"> [Psyco]를 쓴 후 걸린 시간||
||mgenome ||||<style="TEXT-ALIGN: center">173초 ||||<style="TEXT-ALIGN: center">15.5초 ||
||yong27 ||||<style="TEXT-ALIGN: center">107초 ||||<style="TEXT-ALIGN: center">12.7초 ||
||windist ||||<style="TEXT-ALIGN: center">9.5초 ||||<style="TEXT-ALIGN: center">3.5초 ||

[Recursion]을 써서 만들었습니다.

--- ["yong27"] 님 감사합니다.

   1 def ThreePlusOne(n, count=0):
   2     count += 1
   3     if n==1:
   4         return count
   5     elif n%2==0:
   6         return ThreePlusOne(n/2, count) # return을 빼먹으면 None이  리턴
   7     else:
   8         return ThreePlusOne(n*3+1, count) #return을 빼먹으면 None이 리턴
   9         
  10 def main():
  11     i, j = raw_input().split()
  12 
  13     b = 0
  14     for a in range(int(i), int(j)+1):
  15         temp = ThreePlusOne(a)
  16         if b < temp: b = temp
  17     print i, j, b
  18 
  19 if __name__ == '__main__':
  20     #import psyco
  21     #psyco.bind(main)
  22     main()

3N+1Problem 참조

AlgorithmQuiz/3Plus1/mgenome (last edited 2013-08-09 16:13:17 by 61)

web biohackers.net