Advertisement
Guest User

Untitled

a guest
Sep 17th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.95 KB | None | 0 0
  1. 4 +/@$/@$~/@$~ 3
  2. 1.34078e154
  3. t=.+/@$/@$~/@$~ NB. define a function
  4. 4 t 3
  5. 1.34078e154
  6. 2 t 2
  7. 4
  8.  
  9. import Data.List
  10. t x=genericLength.(iterate(sequence.map(const$replicate x[]))[[]]!!)
  11.  
  12. Prelude> :m +Data.List
  13. Prelude Data.List> let t x=genericLength.(iterate(sequence.map(const$replicate x[]))[[]]!!)
  14. Prelude Data.List> t 2 2
  15. 4
  16. Prelude Data.List> t 2 4
  17. 65536
  18. Prelude Data.List> t 4 3
  19.  
  20. ~])*1+{[]+*{*}*}*
  21.  
  22. ~])*{[]+*{*}*}*
  23.  
  24. */@$~/1,~$~/
  25.  
  26. h=:[:*/@$~/1,~$~/
  27.  
  28. h 2 4
  29. 65536
  30.  
  31. */@$~/1,~$~/".1!:1]1
  32.  
  33. ~1{1{0{+}?}?}{@+@*}:?~
  34.  
  35. ~1{1{*}?}{@+@*}:?~
  36.  
  37. a,b=map(int,raw_input().split())
  38. exec"eval('*'.join('a'*"*b+'1'+'))'*b
  39.  
  40. sub t
  41. {
  42. ($x,$y,$z)=@_;
  43. $y>1&&t($x,$y-1,eval$x."*$x"x($z-1||1))||$z
  44. }
  45.  
  46. print t(2,4,1)
  47.  
  48. type B=BigInt
  49. def r(a:B,b:B,f:(B,B)=>B):B=if(b>1)f(a,r(a,b-1,f))else a
  50. def h(a:B,b:B)=r(a,b,r(_,_,r(_,_,(_+_))))
  51.  
  52. type B=BigInt
  53. def recursive (a:B, b:B, f:(B,B)=>B): B =
  54. if (b>1) f (a, recursive (a, b-1, f))
  55. else a
  56. recursive (2, 3, recursive (_, _, recursive (_, _, (_ + _))))
  57.  
  58. type B=BigInt
  59. def p (a:B, b:B):B = a+b
  60. def m (a:B, b:B):B = if (b>1) p (a, m (a, b-1)) else a
  61. def h (a:B, b:B):B = if (b>1) m (a, h (a, b-1)) else a
  62. def t (a:B, b:B):B = if (b>1) h (a, t (a, b-1)) else a
  63.  
  64. def r (a:B, b:B, f:(B,B)=>B):B =
  65. if (b>1) f(a, r(a, b-1, f)) else a
  66. r (4, 3, r (_,_, r(_,_, (_+_))))
  67.  
  68. def h(a:B,b:B)=r(a,b,r(_,_,(_*_))) // size -7, penalty + 5
  69. def h(a:B,b:B)=r(a,b,r(_,_,r(_,_,(_+_))))
  70.  
  71. type B=BigInt
  72. def p(a:B,b:B):B=a+b
  73. import annotation._
  74. @tailrec
  75. def m(a:B,b:B,c:B=0):B=if(b>0)m(a,b-1,p(a,c))else c
  76. @tailrec
  77. def h(a:B,b:B,c:B=1):B=if(b>0)h(a,b-1,m(a,c))else c
  78. @tailrec
  79. def t(a:B,b:B,c:B=1):B=if(b>0)t(a,b-1,h(a,c))else c
  80.  
  81. // 124 = 119-5 bonus
  82. type B=BigInt
  83. def r(a:B,b:B,c:B,f:(B,B)=>B):B=if(b>0)r(a,b-1,f(a,c),f)else c
  84. def t(a:B,b:B)=r(a,b,1,r(_,_,1,r(_,_,0,(_+_))))
  85.  
  86. // 115 without bonus
  87. type B=BigInt
  88. def r(a:B,b:B,c:B,f:(B,B)=>B):B=if(b>0)r(a,b-1,f(a,c),f)else c
  89. def t(a:B,b:B)=r(a,b,1,r(_,_,1,(_*_)))
  90.  
  91. timed ("t(4,3)")(t(4,3))
  92. t(4,3): 1
  93. scala> t(4,3)
  94. res89: B = 13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096
  95.  
  96. def e(x,y)
  97. r=1
  98. (1..y).each{t=x
  99. (2..r).each{t*=x}
  100. r=t}
  101. r
  102. end
  103.  
  104. m@f_:=Fold[f,1,#2~Table~{#}]&;
  105.  
  106. m[m@Sum]
  107.  
  108. m[m@Sum][3, 4]
  109.  
  110. r=xrange
  111. def m(x,y):
  112. i=0
  113. for n in r(y):i+=x
  114. return i
  115. def e(x,y):
  116. i=1
  117. for n in r(1,y+1):i=m(i,x)
  118. return i
  119. def t(x,y):
  120. i=1
  121. for n in r(y):i=e(x,i)
  122. return i
  123.  
  124. t(2, 4)
  125.  
  126. import sys
  127. p=lambda y:y and x*p(y-1)or 1
  128. t=lambda y:y>1 and p(t(y-1))or x
  129. x,y=map(long,sys.argv[1:])
  130. print t(y)
  131.  
  132. x,y,z;
  133. double R(){return--y?!z?y=R(),R(z=1):x*R():x;}
  134. main(){
  135. scanf("%d%d",&x,&y);
  136. printf("%fn",R());
  137. }
  138.  
  139. USING: eval io kernel locals math prettyprint sequences ;
  140. IN: g
  141. :: c ( y x o! -- v )
  142. o 0 = [ x y * ] [ o 1 - o!
  143. y x <repetition> 1 [ o c ] reduce ] if ;
  144. contents eval( -- x y ) swap 2 c .
  145.  
  146. USING: eval io kernel locals math prettyprint sequences ;
  147. IN: script
  148.  
  149. ! Calculate by opcode:
  150. ! 0 => x * y, multiplication
  151. ! 1 => x ^ y, exponentiation
  152. ! 2 => x ^^ y, tetration
  153. :: calculate ( y x opcode! -- value )
  154. opcode 0 = [
  155. x y *
  156. ] [
  157. ! Decrement the opcode. Tetration is repeated exponentiation,
  158. ! and exponentiation is repeated multiplication.
  159. opcode 1 - opcode!
  160.  
  161. ! Do right-associative reduction. The pattern is
  162. ! seq reverse 1 [ swap ^ ] reduce
  163. ! but a repetition equals its own reverse, and 'calculate'
  164. ! already swaps its inputs.
  165. y x <repetition> 1 [ opcode calculate ] reduce
  166. ] if ;
  167.  
  168. contents eval( -- x y ) ! Read input.
  169. swap 2 calculate . ! Calculate tetration. Print result.
  170.  
  171. USING: eval kernel math.functions prettyprint sequences ;
  172. contents eval( -- x y ) swap <repetition> 1 [ swap ^ ] reduce .
  173.  
  174. i f x 1=x;i f x n=f$i f x$n-1
  175. t=i(o n->i(o n)n)(+)4
  176.  
  177. bump op n a = iterate (op n) n !! (fromIntegral $ a-1)
  178. tetrate = iterate bump (+) !! 3
  179.  
  180. Prelude> let i f x 1=x;i f x n=f$i f x$n-1
  181. (0.00 secs, 1564024 bytes)
  182. Prelude> let t=i(o n->i(o n)n)(*)3
  183. (0.00 secs, 1076200 bytes)
  184. Prelude> t 4 3
  185. 13407807929942597099574024998205846127479365820592393377723561443721764030073546
  186. 976801874298166903427690031858186486050853753882811946569946433649006084096
  187. (0.01 secs, 1081720 bytes)
  188.  
  189. function t(i){y=i.split(' ');a=y[0];b=y[1];return+b&&p(a,t(a+' '+(b-1)))||1}function p(a,b){return+b&&a*p(a,b-1)||1}
  190.  
  191. 1.3407807929942597e+154
  192.  
  193. r=lambda x,y:(x for _ in range(y));t=lambda x,y:reduce(lambda y,x:reduce(lambda x,y:sum(r(x,y)),r(x,y)),r(x,y),1)
  194.  
  195. data N=Z|S N
  196. a&+Z=a
  197. a&+S b=S$a&+b
  198. _&*Z=Z
  199. a&*S b=a&+(a&*b)
  200. _&^Z=S Z
  201. a&^S b=a&*(a&^b)
  202. _&>Z=S Z
  203. a&>S b=a&^(a&>b)
  204.  
  205. f 0=Z
  206. f a=S$f$a-1
  207. t Z=0
  208. t(S a)=1+t a
  209. main=interact$show.f.([x,y]->x&>y).map(f.read).words
  210.  
  211. (lambda(b c)(let((r b)u)(dotimes(c c r)(setf u 1 r(dotimes(c b u)(setf u(* u r)))))))
  212.  
  213. (lambda(a b)(eval`(*,@(loop for x below b nconc(loop for x below a nconc`(,a,a))))))
  214.  
  215. a,b=input().split()
  216. r=1;exec("r=eval((a+'*')*r+'1');"*int(b))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement