Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Clean up

  • Loading branch information...
commit ad898f8644f820db8aea3a4fd822bf336895af53 1 parent b40054c
Ivan Krasilnikov infnty authored
Showing with 8 additions and 18,225 deletions.
  1. +8 −0 LICENSE
  2. +0 −112 acm.uva.es/10241/diophantine.out
  3. +0 −54 acm.uva.es/10433/temp/p1.c
  4. +0 −39 acm.uva.es/10531/temp/in
  5. +0 −30 acm.uva.es/10531/temp/oa
  6. +0 −80 acm.uva.es/10531/temp/p1.c
  7. +0 −151 acm.uva.es/10531/temp/p2.c
  8. +0 −122 acm.uva.es/10531/temp/p3.c
  9. +0 −141 acm.uva.es/10531/temp/p4a.c
  10. +0 −140 acm.uva.es/10531/temp/p4b.c
  11. +0 −163 acm.uva.es/10531/temp/p4c.c
  12. +0 −24 acm.uva.es/10590/temp/p1.cpp
  13. +0 −93 acm.uva.es/10619/temp/p1.c
  14. +0 −69 acm.uva.es/10619/temp/p2.c
  15. +0 −68 acm.uva.es/10619/temp/p3.c
  16. +0 −67 acm.uva.es/10619/temp/p4.c
  17. +0 −23 acm.uva.es/10623/temp/p1.c
  18. +0 −19 acm.uva.es/10623/temp/p2.c
  19. +0 −48 acm.uva.es/10643/temp/x.c
  20. +0 −73 acm.uva.es/10643/temp/y.c
  21. +0 −30 acm.uva.es/10722/temp1/p1.c
  22. +0 −97 acm.uva.es/10722/temp1/p2.c
  23. +0 −105 acm.uva.es/10722/temp1/p3.c
  24. +0 −128 acm.uva.es/10722/temp1/p4.c
  25. +0 −129 acm.uva.es/10755/temp/p1.c
  26. +0 −78 acm.uva.es/10755/temp/p2.c
  27. +0 −207 acm.uva.es/10778/temp/p1.c
  28. +0 −209 acm.uva.es/10778/temp/p2.c
  29. +0 −235 acm.uva.es/10778/temp/p3.c
  30. BIN  acm.uva.es/10825/tmp.rar
  31. BIN  acm.uva.es/10833/temp/temp.tar.bz2
  32. +0 −100 acm.uva.es/10835/contest/temp/p.c
  33. +0 −10 acm.uva.es/10836/temp/alg1/in
  34. +0 −46 acm.uva.es/10836/temp/alg1/p1.c
  35. +0 −57 acm.uva.es/10836/temp/alg1/p2.c
  36. +0 −72 acm.uva.es/10836/temp/alg1/p3.c
  37. +0 −134 acm.uva.es/10836/temp/alg1/p4.c
  38. +0 −140 acm.uva.es/10836/temp/alg1/p5.c
  39. +0 −150 acm.uva.es/10836/temp/alg1/p6.c
  40. +0 −149 acm.uva.es/10836/temp/alg2/q1.c
  41. +0 −184 acm.uva.es/10836/temp/alg2/q2.c
  42. +0 −201 acm.uva.es/10836/temp/alg2/q3.c
  43. +0 −204 acm.uva.es/10836/temp/alg2/q4.c
  44. +0 −31 acm.uva.es/10836/temp/count.c
  45. +0 −28 acm.uva.es/10836/temp/rnd.c
  46. +0 −113 acm.uva.es/10846/temp/p1.c
  47. +0 −106 acm.uva.es/10846/temp/p2.wa.c
  48. +0 −67 acm.uva.es/10846/temp/p3.c
  49. +0 −65 acm.uva.es/10846/temp/p4.c
  50. +0 −77 acm.uva.es/10846/temp/p5.c
  51. +0 −68 acm.uva.es/10846/temp/p6.tle.c
  52. +0 −69 acm.uva.es/10846/temp/p7.c
  53. BIN  acm.uva.es/10853/temp/temp.tar.bz2
  54. BIN  acm.uva.es/10861/temp/temp.tar.bz2
  55. +0 −21 acm.uva.es/10863/ac2/in
  56. BIN  acm.uva.es/10863/temp.tar.bz2
  57. +0 −32 acm.uva.es/10866/ac2/in
  58. +0 −3  acm.uva.es/10866/temp/a
  59. +0 −147 acm.uva.es/10866/temp/p4.c
  60. +0 −24 acm.uva.es/10866/temp/x.c
  61. +0 −65 acm.uva.es/10866/temp/y
  62. BIN  acm.uva.es/10867/temp/temp.tar.bz2
  63. BIN  acm.uva.es/10869/temp.tar.bz2
  64. +0 −120 acm.uva.es/10870/temp/p1.c
  65. +0 −156 acm.uva.es/10870/temp/p2.c
  66. +0 −143 acm.uva.es/10870/temp/p3.c
  67. +0 −148 acm.uva.es/10870/temp/p4.c
  68. +0 −27 acm.uva.es/10870/temp/pwr.c
  69. +0 −4 acm.uva.es/10871/ac1/in
  70. BIN  acm.uva.es/10872/temp/temp.tar.bz2
  71. +0 −7 acm.uva.es/10873/ac1/in
  72. +0 −10 acm.uva.es/10877/ac2/in
  73. +0 −45 acm.uva.es/10877/ac3/temp/mksym.c
  74. +0 −8 acm.uva.es/10877/ac3/temp/sym
  75. +0 −10 acm.uva.es/10877/ac4/in
  76. +0 −45 acm.uva.es/10878/ac1/in
  77. +0 −4 acm.uva.es/10879/ac1/in
  78. +0 −7 acm.uva.es/10879/ac2/in
  79. +0 −7 acm.uva.es/10879/ac3/in
  80. +0 −8 acm.uva.es/10882/ac1/in
  81. +0 −9 acm.uva.es/10883/ac1/in
  82. +0 −9 acm.uva.es/10883/ac2/in
  83. +0 −85 acm.uva.es/10884/temp/p1.c
  84. +0 −152 acm.uva.es/10884/temp/p2.c
  85. +0 −64 acm.uva.es/10885/temp/p2.c
  86. +0 −13 acm.uva.es/10885/temp/p2.sol
  87. +0 −16 acm.uva.es/10886/temp/in
  88. +0 −50 acm.uva.es/10886/temp/p1.c
  89. +0 −49 acm.uva.es/10886/temp/p2.c
  90. +0 −43 acm.uva.es/10886/temp/p3.c
  91. +0 −88 acm.uva.es/10886/temp/p4.c
  92. +0 −90 acm.uva.es/10886/temp/p5.c
  93. +0 −88 acm.uva.es/10886/temp/q1.c
  94. +0 −32 acm.uva.es/10886/temp/q2.c
  95. +0 −35 acm.uva.es/10886/temp/q3.c
  96. BIN  acm.uva.es/10887/ac2/temp.rar
  97. +0 −9 acm.uva.es/10891/ac1/in
  98. +0 −9 acm.uva.es/10891/ac2/in
  99. +0 −9 acm.uva.es/10892/ac1/in
  100. +0 −9 acm.uva.es/10892/ac2/in
  101. +0 −6 acm.uva.es/10894/ac1/in
  102. +0 −7 acm.uva.es/10898/ac1/in
  103. +0 −79 acm.uva.es/10898/ac2/temp/p1.c
  104. +0 −84 acm.uva.es/10898/ac2/temp/p2.c
  105. +0 −84 acm.uva.es/10898/ac2/temp/p3.c
  106. +0 −80 acm.uva.es/10898/ac2/temp/p4.c
  107. +0 −93 acm.uva.es/10898/ac2/temp/p5.c
  108. +0 −94 acm.uva.es/10898/ac2/temp/p6.c
  109. +0 −96 acm.uva.es/10898/ac2/temp/p7.c
  110. +0 −92 acm.uva.es/10898/ac2/temp/p8.c
  111. +0 −117 acm.uva.es/10898/ac2/temp/p9.c
  112. +0 −55 acm.uva.es/109/temp/hull1.c
  113. +0 −64 acm.uva.es/109/temp/hull2.c
  114. +0 −19 acm.uva.es/10903/ac1/in
  115. +0 −102 acm.uva.es/10906/temp/in
  116. +0 −20 acm.uva.es/10906/temp/oc
  117. +0 −76 acm.uva.es/10906/temp/p1.c
  118. +0 −77 acm.uva.es/10906/temp/p2.c
  119. +0 −68 acm.uva.es/10906/temp/p3.c
  120. +0 −68 acm.uva.es/10906/temp/p4.c
  121. +0 −79 acm.uva.es/10906/temp/p5.c
  122. +0 −29 acm.uva.es/10911/ac1/in
  123. +0 −29 acm.uva.es/10911/ac2/in
  124. +0 −5 acm.uva.es/10914/ac1/in
  125. +0 −5 acm.uva.es/10914/ac2/in
  126. +0 −15 acm.uva.es/10915/ac1/in
  127. +0 −15 acm.uva.es/10915/ac2/in
  128. 0  acm.uva.es/{10934/q.c → 10934.c}
  129. BIN  acm.uva.es/10934/drv.rar
  130. +0 −46 acm.uva.es/10952/temp/in1
  131. +0 −56 acm.uva.es/10952/temp/in2
  132. +0 −141 acm.uva.es/10952/temp/p1.c
  133. +0 −147 acm.uva.es/10952/temp/p2.c
  134. +0 −147 acm.uva.es/10952/temp/p2b.c
  135. +0 −163 acm.uva.es/10952/temp/p3.c
  136. +0 −136 acm.uva.es/10952/temp/p4.c
  137. +0 −218 acm.uva.es/10952/temp/p5.c
  138. +0 −109 acm.uva.es/10952/temp/q1.c
  139. +0 −90 acm.uva.es/10952/temp/q4.c
  140. +0 −98 acm.uva.es/10952/temp/q5.c
  141. +0 −26 acm.uva.es/10952/temp/r1.c
  142. +0 −83 acm.uva.es/10952/temp/r2.c
  143. +0 −83 acm.uva.es/10952/temp/r3.c
  144. +0 −51 acm.uva.es/10957/ac1.probably_incorrect/in1
  145. +0 −33 acm.uva.es/10957/ac1.probably_incorrect/in2
  146. +0 −188 acm.uva.es/10957/ac1.probably_incorrect/temp/p1.c
  147. +0 −202 acm.uva.es/10957/ac1.probably_incorrect/temp/p2.c
  148. +0 −193 acm.uva.es/10957/ac1.probably_incorrect/temp/p3.c
  149. +0 −191 acm.uva.es/10957/ac1.probably_incorrect/temp/p4.c
  150. +0 −3  acm.uva.es/10958/ac1/in
  151. +0 −3  acm.uva.es/10958/ac3/in
  152. +0 −97 acm.uva.es/10969/temp/p1.c
  153. +0 −58 acm.uva.es/10970/temp/p.c
  154. +0 −116 acm.uva.es/10970/temp/p1.c
  155. +0 −114 acm.uva.es/10970/temp/p2.c
  156. +0 −28 acm.uva.es/10975/ac2/in
  157. +0 −28 acm.uva.es/10975/pe1/in
  158. +0 −20 acm.uva.es/10979/temp/in1
  159. +0 −27 acm.uva.es/10979/temp/in2
  160. +0 −119 acm.uva.es/10979/temp/in3
  161. +0 −28 acm.uva.es/10979/temp/in4
  162. +0 −20 acm.uva.es/10979/temp/in5
  163. +0 −7 acm.uva.es/10979/temp/in6
  164. +0 −102 acm.uva.es/10979/temp/p1.cc
  165. +0 −116 acm.uva.es/10981/temp/p1.cc
  166. +0 −111 acm.uva.es/10981/temp/p2.cc
  167. +0 −134 acm.uva.es/10981/temp/p3.cc
  168. +0 −123 acm.uva.es/10981/temp/p4.cc
  169. +0 −126 acm.uva.es/10981/temp/p5.cc
  170. +0 −100 acm.uva.es/10981/temp/p6.cc
  171. +0 −16 acm.uva.es/10981/temp/r.cc
  172. +0 −7 acm.uva.es/10981/temp/r2.c
  173. +0 −137 acm.uva.es/10981/temp/t1.cc
  174. +0 −8 acm.uva.es/10986/stl/in
  175. 0  acm.uva.es/{10997/p.cc → 10997.cc}
  176. +0 −63 acm.uva.es/10997/C.1.dat
  177. +0 −11 acm.uva.es/10997/C.1.diff
  178. +0 −39 acm.uva.es/11012/ac2/in
  179. +0 −40 acm.uva.es/11014/op
  180. +0 −40 acm.uva.es/11014/oq
  181. +0 −43 acm.uva.es/11014/temp/p1.cc
  182. +0 −49 acm.uva.es/11014/temp/p2a.cc
  183. +0 −55 acm.uva.es/11014/temp/p2b.cc
  184. +0 −61 acm.uva.es/11014/temp/p2c.cc
  185. +0 −58 acm.uva.es/11014/temp/p2d.cc
  186. +0 −63 acm.uva.es/11014/temp/p2e.cc
  187. +0 −85 acm.uva.es/11014/temp/p2f.cc
  188. +0 −53 acm.uva.es/11014/temp/p2g.cc
  189. +0 −44 acm.uva.es/11014/temp/p2h.cc
  190. +0 −54 acm.uva.es/11014/temp/p2i.cc
  191. +0 −54 acm.uva.es/11014/temp/p2j.cc
  192. +0 −63 acm.uva.es/11014/temp/p3a.cc
  193. +0 −36 acm.uva.es/11014/temp/p3b.cc
  194. +0 −32 acm.uva.es/11014/temp/p3c.cc
  195. +0 −37 acm.uva.es/11014/temp/p3d.cc
  196. +0 −36 acm.uva.es/11014/temp/p3e.cc
  197. +0 −18 acm.uva.es/11014/temp/q.cc
  198. +0 −17 acm.uva.es/11014/temp/z.cc
  199. +0 −13 acm.uva.es/11026/ac1/in
  200. 0  acm.uva.es/{11028/p.cc → 11028.cc}
  201. +0 −24 acm.uva.es/11028/etc/p1.cc
  202. +0 −30 acm.uva.es/11028/etc/p2.cc
  203. +0 −27 acm.uva.es/11028/etc/p3.cc
  204. +0 −26 acm.uva.es/11028/etc/p4.cc
  205. +0 −30 acm.uva.es/11028/etc/z1
  206. +0 −20 acm.uva.es/11028/etc/z2
  207. +0 −16 acm.uva.es/11035/ac1/in
  208. +0 −16 acm.uva.es/11035/ac2/in
  209. +0 −7 acm.uva.es/11037/in1
  210. +0 −12 acm.uva.es/11037/in2
  211. +0 −1  acm.uva.es/11043/in1
  212. +0 −1  acm.uva.es/11043/in2
  213. +0 −5 acm.uva.es/111/test1.in
  214. +0 −6 acm.uva.es/111/test2.in
  215. +0 −27 acm.uva.es/116/ac1/in
  216. +0 −27 acm.uva.es/116/ac2/in
  217. +0 −2  acm.uva.es/128/ac1/in
  218. +0 −4 acm.uva.es/128/ac2/in
  219. +0 −24 acm.uva.es/135/temp/draw.c
  220. +0 −66 acm.uva.es/137/temp/p1.c
  221. +0 −136 acm.uva.es/137/temp/p2.c
  222. +0 −201 acm.uva.es/137/temp/p3.c
  223. 0  acm.uva.es/{155/p.c → 155.c}
  224. +0 −2  acm.uva.es/155/1
  225. +0 −72 acm.uva.es/165/temp/p1.c
  226. +0 −77 acm.uva.es/165/temp/p2.c
  227. +0 −10 acm.uva.es/172/in1
  228. +0 −1  acm.uva.es/172/in2
  229. +0 −71 acm.uva.es/177/temp/p1.c
  230. +0 −140 acm.uva.es/191/temp/p1.c
  231. +0 −97 acm.uva.es/200/temp/x.c
  232. +0 −8 acm.uva.es/214/wa1/in
  233. +0 −39 acm.uva.es/217/temp/gr.m
  234. +0 −21 acm.uva.es/217/temp/in
  235. +0 −83 acm.uva.es/217/temp/p1.c
  236. +0 −101 acm.uva.es/217/temp/p2.c
  237. +0 −144 acm.uva.es/217/temp/p3.c
  238. +0 −143 acm.uva.es/217/temp/p4.c
  239. +0 −502 acm.uva.es/255/ac1/in
  240. +0 −502 acm.uva.es/255/ac2/in
  241. +0 −5 acm.uva.es/275/ac1/in
  242. +0 −45 acm.uva.es/291/temp/g.c
  243. +0 −44 acm.uva.es/291/temp/r
  244. +0 −4 acm.uva.es/294/test1.in
  245. +0 −7 acm.uva.es/297/test1.in
  246. +0 −16 acm.uva.es/333/test1.in
  247. +0 −31 acm.uva.es/336/ac1/in
  248. +0 −31 acm.uva.es/336/ac2/in
  249. +0 −3  acm.uva.es/355/ac2/in
  250. +0 −21 acm.uva.es/361/in.2
  251. +0 −110 acm.uva.es/361/temp/p1.c
  252. +0 −110 acm.uva.es/361/temp/p2.c
  253. +0 −1  acm.uva.es/390/in1
  254. +0 −5 acm.uva.es/390/in2
  255. +0 −16 acm.uva.es/452/ac1/in
  256. +0 −16 acm.uva.es/452/ac2.slower/in
  257. +0 −16 acm.uva.es/452/ac3/in
  258. +0 −37 acm.uva.es/459/ac1/test1.in
  259. +0 −13 acm.uva.es/459/ac2/in
  260. +0 −26 acm.uva.es/469/ac1/in
  261. +0 −26 acm.uva.es/469/ac2/in
  262. 0  acm.uva.es/{478/p.c → 478.c}
  263. +0 −5 acm.uva.es/478/i
  264. +0 −14 acm.uva.es/478/inc
  265. +0 −15 acm.uva.es/478/inr
  266. +0 −17 acm.uva.es/478/int
  267. +0 −20 acm.uva.es/481/ac1/in
  268. +0 −50 acm.uva.es/481/temp/p1.c
  269. +0 −44 acm.uva.es/481/temp/p2.c
  270. +0 −10 acm.uva.es/497/in2
  271. +0 −14 acm.uva.es/497/in3
  272. +0 −25 acm.uva.es/497/in4
  273. +0 −6 acm.uva.es/548/ac1/in
  274. +0 −6 acm.uva.es/548/ac2/in
  275. +0 −36 acm.uva.es/561/temp/p1.c
  276. +0 −36 acm.uva.es/563/ac1/in
  277. +0 −36 acm.uva.es/563/ac2/in
  278. +0 −94 acm.uva.es/589/temp/p1.cc
  279. +0 −91 acm.uva.es/607/temp/p1.c
  280. +0 −5 acm.uva.es/621/pe/in
  281. +0 −11 acm.uva.es/658/ac1/in
  282. +0 −33 acm.uva.es/658/ac2/in
  283. BIN  acm.uva.es/658/temp/temp.tar.bz2
  284. +0 −7 acm.uva.es/679/ac1/in
  285. +0 −7 acm.uva.es/679/ac2/in
  286. +0 −7 acm.uva.es/679/ac3/in
  287. +0 −39 acm.uva.es/681/ac1/in
  288. +0 −40 acm.uva.es/681/ac2/in
  289. +0 −42 acm.uva.es/707/ac2/in
  290. +0 −5 acm.uva.es/711/ac2/in
  291. +0 −97 acm.uva.es/711/temp/p1.c
  292. +0 −71 acm.uva.es/722/temp/p1.c
  293. +0 −79 acm.uva.es/722/temp/p3.c
  294. +0 −430 acm.uva.es/722/temp/q2.c
  295. 0  acm.uva.es/748/WRONG.!!!
  296. 0  acm.uva.es/{748/p.c → 748_wrong.c}
  297. +0 −55 acm.uva.es/755/ac1/in
  298. +0 −58 acm.uva.es/755/ac2/in
  299. +0 −20 acm.uva.es/820/ac1/in
  300. +0 −20 acm.uva.es/820/ac2/in
Sorry, we could not display the entire diff because too many files (632) changed.
8 LICENSE
View
@@ -0,0 +1,8 @@
+Unless otherwise noted here or in a file itself, source code files in
+this repository have been authored by Ivan Krasilnikov and are hereby
+released into the public domain.
+
+Some files contain partial or full copies of original problem statements,
+sample input/output, archived web-pages. Such files or portions of files,
+and files in third_party directory have been authored by third parties
+and are copyright by their respective authors.
112 acm.uva.es/10241/diophantine.out
View
@@ -1,112 +0,0 @@
-1
-9
-36
-196
-225
-324
-900
-1225
-4225
-11025
-41616
-53361
-88209
-108900
-176400
-324900
-374544
-1413721
-8643600
-12723489
-43956900
-48024900
-52490025
-158407396
-432224100
-468506025
-846984609
-1631432881
-8283548196
-14682895929
-25300083600
-55420693056
-82995848100
-142249665600
-457239678025
-498786237504
-675585363600
-1882672131025
-8132746129209
-12194587805625
-16944049179225
-63955431761796
-127740041301796
-575598885856164
-796926124814400
-974193625805625
-1285888320711225
-2172602007770041
-4756207086867600
-5877766022228100
-19553418069930369
-73804512832419600
-78090627485682009
-114710414839347600
-664240615491776400
-1404786532826348100
-2507180834294496361
-2833071028126139025
-7652084567472022500
-22564627508650467249
-49474065660357105625
-85170343853180456676
-103009824785692843396
-199613587569002860176
-749826196984772523009
-766533094678624110084
-1365534357790776782400
-2025701206141968155025
-2893284510173841030625
-26039560591564569275625
-73475315219940235232400
-92502707947137334022400
-98286503002057414584576
-514629226242827525852100
-658184727384126282978225
-884578527018516731261184
-2921059734470185253198400
-3338847817559778254844961
-7199831065357158280252209
-30049630358038004293604649
-30986815651400701675956681
-83067328726704540259272196
-113422539294030403250144100
-317243673064791077618722500
-705509969089781571229484100
-1020802853646273629251296900
-3853027488179473932250054441
-4212166111404800993143938225
-5353173161903826263556447025
-34677247393615265390250489969
-69132777139733236822209189609
-74594368693872730015492410000
-130889512058808083293251706896
-152910792232501915285941267225
-1178005608529272749639265362064
-4446390382511295358038307980025
-4810207340629922936396456664900
-6073940611585988561928305722500
-6774306649724767427005271097600
-40017513442601658222344771820225
-55683706715494374550686636110400
-66985660019768984849371924908196
-73702684612392858376746072080400
-151046383493325234090009219613956
-663812918895887474609694358375209
-1359417451439927106810082976525604
-5131130648390546663702275158894481
-8758618149740884101499623707907225
-35524541072381125235676320801486025
-46180175835514919973320476430050329
-60153048103383854522005973075150400
-65046891745147247744323041849672900
54 acm.uva.es/10433/temp/p1.c
View
@@ -1,54 +0,0 @@
-#include <stdio.h>
-
-int a[65536], b[65536], n;
-
-int check()
-{
- int i, j, k, c;
-
- for (i = n - 1; i >= 0 && a[i] == 0; i--);
-
- if (i < 0 || (i == 0 && a[0] == 1))
- return 0;
-
- for (i = 0; i < n; i++)
- b[i] = 0;
-
- for (i = 0; i < n; i++) {
- if (a[i] != 0) {
- for (c = 0, j = 0, k = i; k < n; j++, k++, c /= 10)
- b[k] = (c += b[k] + a[i] * a[j]) % 10;
- }
- if (b[i] != a[i]) return 0;
- }
-
- return 1;
-}
-
-int main()
-{
- int i, j, c;
-
- for (;;) {
- for (n = 0; (c = getchar()) != EOF && c != '\n';)
- if ('0' <= c && c <= '9') a[n++] = c - '0';
-
- if (n == 0) {
- if (c == EOF) break;
- continue;
- }
-
- for (i = 0, j = n - 1; i < j;) {
- c = a[i];
- a[i++] = a[j];
- a[j--] = c;
- }
-
- if (check())
- printf("Automorphic number of %d-digit.\n", n);
- else
- printf("Not an Automorphic number.\n");
- }
-
- return 0;
-}
39 acm.uva.es/10531/temp/in
View
@@ -1,39 +0,0 @@
-7
-
-2 2
-0.5 0.5
-0.5 0.5
-
-5 5
-0.3 0.3 0.3 0.3 0.3
-0.3 1.0 0.3 1.0 0.3
-0.3 1.0 0.3 0.3 0.3
-0.3 1.0 0.3 1.0 1.0
-0.3 0.3 0.3 0.3 0.3
-
-3 3
-0.5 0.5 0.5
-0.5 1.0 0.5
-0.2 0.5 0.5
-
-3 3
-0.5 0.5 0.5
-0.5 0.9 0.5
-0.2 0.5 0.5
-
-5 5
-0.5 0.5 0.5 0.5 0.5
-0.5 0.5 0.5 0.5 0.5
-0.5 0.5 0.5 0.5 0.5
-0.5 0.5 0.5 0.5 0.5
-0.5 0.5 0.5 0.5 0.5
-
-5 6
-0.5 0.5 0.5 0.5 0.5 0.5
-0.5 0.5 0.5 0.5 0.5 0.5
-0.5 0.5 0.0 1.0 0.5 0.5
-0.5 0.5 0.5 0.5 0.5 0.5
-0.5 0.5 0.5 0.5 0.5 0.5
-
-1 1
-0.5
30 acm.uva.es/10531/temp/oa
View
@@ -1,30 +0,0 @@
-0.000000 0.333333
-0.333333 0.000000
-
-0.000000 0.158575 0.158575 0.290498 0.290498
-0.169997 1.000000 0.190249 1.000000 0.290498
-0.169997 1.000000 0.158575 0.290498 0.290498
-0.169997 1.000000 0.158575 1.000000 1.000000
-0.169997 0.169997 0.000000 0.000000 0.000000
-
-0.000000 0.333333 0.333333
-0.208333 1.000000 0.333333
-0.083333 0.208333 0.000000
-
-0.000000 0.333333 0.362069
-0.229885 0.827586 0.333333
-0.103448 0.229885 0.000000
-
-0.000000 0.306323 0.405105 0.460020 0.487886
-0.306323 0.326223 0.363506 0.415657 0.460020
-0.405105 0.363506 0.347423 0.363506 0.405105
-0.460020 0.415657 0.363506 0.326223 0.306323
-0.487886 0.460020 0.405105 0.306323 0.000000
-
-0.000000 0.297131 0.387883 0.442577 0.464531 0.487493
-0.316706 0.338355 0.330075 0.418980 0.387451 0.461218
-0.415218 0.382289 0.000000 1.000000 0.426257 0.432297
-0.469424 0.464337 0.238489 0.323881 0.326913 0.340870
-0.491602 0.464554 0.405177 0.344487 0.259860 0.000000
-
-0.000000
80 acm.uva.es/10531/temp/p1.c
View
@@ -1,80 +0,0 @@
-#include <stdio.h>
-#include <assert.h>
-
-#define EPS 1e-8
-
-/* rows are numbered 0,1,...,n-1
- columns: 0,1,...,m-1 */
-
-int n, m;
-double P[8][8];
-
-int fgot[8][256], id;
-double ftab[8][256];
-
-/* returns the probability of generating a valid maze, provided that
- the rows 0,1,...,r-1 have already been generated, and there's path from
- (0,0) to (r-1,i) if ((A >> i) & 1) == 1 */
-double f(int r, int A)
-{
- int i, j, k, B, C;
- double p;
-
- if (fgot[r][A] == id) return ftab[r][A];
- fgot[r][A] = id;
- ftab[r][A] = 0.;
-
- if (r == n) return ftab[r][A] = (((A >> (m - 1)) & 1) ? 1. : 0.);
- if (A == 0) return ftab[r][A] = 0.;
-
- /* check all possible 2^m arrangements of blocks on r-th row */
- for (B = 0; B < (1 << m); B++) {
- /* compute the probability of generating such an arrangement */
- p = 1.;
- for (i = 0; i < m; i++)
- p *= (B & (1 << i)) ? P[r][i] : (1. - P[r][i]);
- if (p < EPS) continue;
-
- for (C = 0, i = 0; i < m; i++) {
- if (B & (1 << i)) continue;
-
- for (j = i; j < m && ((B >> j) & 1) == 0; j++)
- if ((A >> j) & 1) { C |= 1 << i; break; }
-
- for (j = i; j >= 0 && ((B >> j) & 1) == 0; j--)
- if ((A >> j) & 1) { C |= 1 << i; break; }
- }
-
- ftab[r][A] += p * f(r+1, C);
- }
-
- return ftab[r][A];
-}
-
-void solve()
-{
-
- id++;
- printf("%.5f\n", f(0,1));
-
-}
-
-int main()
-{
- int i, j, t;
-
- id = 42;
- for (scanf("%d", &t); t-- > 0 && scanf("%d %d", &n, &m) == 2;) {
- assert(1 <= n && n <= 5 && 1 <= m && m <= 6);
-
- for (i = 0; i < n; i++)
- for (j = 0; j < m; j++)
- scanf("%lf", &P[i][j]);
-
- solve();
-
- if (t) printf("\n");
- }
-
- return 0;
-}
151 acm.uva.es/10531/temp/p2.c
View
@@ -1,151 +0,0 @@
-#include <stdio.h>
-#include <assert.h>
-
-#define EPS 1e-12
-
-int fgot[8][128], enforce_r, enforce_b, id, n, m, tflag;
-double P[8][8], R[8][8], ftab[8][128], xtab[8][128];
-
-void transpose()
-{
- double T[8][8];
- int i, j;
-
- for (i = 0; i < n; i++)
- for (j = 0; j < m; j++)
- T[i][j] = P[i][j];
-
- for (i = 0; i < n; i++)
- for (j = 0; j < m; j++)
- P[j][i] = T[i][j];
-
- i = m; m = n; n = i;
-}
-
-/* rows are numbered 0,1,...,n-1
- columns: 0,1,...,m-1 */
-
-/* returns the probability of generating a valid maze, provided that
- the rows 0,1,...,r-1 have already been generated, and there's path from
- (0,0) to (r-1,i) if ((A >> i) & 1) == 1.
-
- enforce_r/enforce_b make this function to use the arrangement enforce_b
- for the row enforce_r.
- */
-double f(int r, int A)
-{
- int i, j, B, C;
- double p;
-
- if (fgot[r][A] == id) return ftab[r][A];
- fgot[r][A] = id;
- ftab[r][A] = 0.;
-
- if (r == n) return ftab[r][A] = (((A >> (m - 1)) & 1) ? 1. : 0.);
- if (A == 0) return ftab[r][A] = 0.;
-
- if (enforce_r == r) {
- B = enforce_b;
- for (C = 0, i = 0; i < m; i++) {
- if (B & (1 << i)) continue;
-
- for (j = i; j < m && ((B >> j) & 1) == 0; j++)
- if ((A >> j) & 1) { C |= 1 << i; break; }
-
- for (j = i; j >= 0 && ((B >> j) & 1) == 0; j--)
- if ((A >> j) & 1) { C |= 1 << i; break; }
- }
-
- return ftab[r][A] = xtab[r+1][C];
- }
-
- for (B = 0; B < (1 << m); B++) {
- p = 1.;
- for (i = 0; i < m; i++)
- p *= (B & (1 << i)) ? P[r][i] : (1. - P[r][i]);
- if (p < EPS) continue;
-
- for (C = 0, i = 0; i < m; i++) {
- if (B & (1 << i)) continue;
-
- for (j = i; j < m && ((B >> j) & 1) == 0; j++)
- if ((A >> j) & 1) { C |= 1 << i; break; }
-
- for (j = i; j >= 0 && ((B >> j) & 1) == 0; j--)
- if ((A >> j) & 1) { C |= 1 << i; break; }
- }
-
- ftab[r][A] += p * f(r+1, C);
- }
-
- return ftab[r][A];
-}
-
-void solve()
-{
- int i, j, r;
- double p;
-
- tflag = 0;
- if (m > n) {
- transpose();
- tflag = 1;
- }
-
- enforce_r = 999;
- id++;
- for (i = n; i >= 0; i--)
- for (j = 0; j < (1 << m); j++)
- xtab[i][j] = f(i, j);
-
- for (r = 0; r < n; r++) {
- for (i = 0; i < m; i++) R[r][i] = 0.;
-
- enforce_r = r;
- for (enforce_b = 0; enforce_b < (1 << m); enforce_b++) {
- for (p = 1., i = 0; i < m; i++)
- p *= (enforce_b & (1 << i)) ? P[r][i] : (1. - P[r][i]);
- /*if (p < EPS) continue; */
-
- id++;
- p *= f(0, 1);
-
- for (i = 0; i < m; i++)
- if (enforce_b & (1 << i)) R[r][i] += p;
- }
-
- for (i = 0; i < m; i++) R[r][i] /= xtab[0][1];
- }
-
- if (tflag == 0) {
- for (i = 0; i < n; i++) {
- for (j = 0; j < m; j++) printf(j ? " %.6f" : "%.6f", R[i][j]);
- printf("\n");
- }
- } else {
- for (i = 0; i < m; i++) {
- for (j = 0; j < n; j++) printf(j ? " %.6f" : "%.6f", R[j][i]);
- printf("\n");
- }
- }
-}
-
-int main()
-{
- int i, j, t;
-
- id = 42;
- for (scanf("%d", &t); t-- > 0 && scanf("%d %d", &n, &m) == 2;) {
- assert(1 <= n && n <= 5 && 1 <= m && m <= 6);
-
- for (i = 0; i < n; i++)
- for (j = 0; j < m; j++)
- scanf("%lf", &P[i][j]);
-
- solve();
-
- if (t) printf("\n");
- }
-
- return 0;
-}
122 acm.uva.es/10531/temp/p3.c
View
@@ -1,122 +0,0 @@
-#include <stdio.h>
-#include <assert.h>
-
-#define EPS 1e-12
-
-int fgot[8][128], enforce_r, enforce_b, id, n, m;
-double P[8][8], R[8][8], ftab[8][128], xtab[8][128];
-
-/* rows are numbered 0,1,...,n-1
- columns: 0,1,...,m-1 */
-
-/* returns the probability of generating a valid maze, provided that
- the rows 0,1,...,r-1 have already been generated, and there's path from
- (0,0) to (r-1,i) if ((A >> i) & 1) == 1.
-
- enforce_r/enforce_b make this function to use the arrangement enforce_b
- for the row enforce_r.
- */
-double f(int r, int A)
-{
- int i, j, B, C;
- double p;
-
- if (fgot[r][A] == id) return ftab[r][A];
- fgot[r][A] = id;
- ftab[r][A] = 0.;
-
- if (r == n) return ftab[r][A] = (((A >> (m - 1)) & 1) ? 1. : 0.);
- if (A == 0) return ftab[r][A] = 0.;
-
- if (enforce_r == r) {
- B = enforce_b;
- for (C = 0, i = 0; i < m; i++) {
- if (B & (1 << i)) continue;
-
- for (j = i; j < m && ((B >> j) & 1) == 0; j++)
- if ((A >> j) & 1) { C |= 1 << i; break; }
-
- for (j = i; j >= 0 && ((B >> j) & 1) == 0; j--)
- if ((A >> j) & 1) { C |= 1 << i; break; }
- }
-
- return ftab[r][A] = xtab[r+1][C];
- }
-
- for (B = 0; B < (1 << m); B++) {
- p = 1.;
- for (i = 0; i < m; i++)
- p *= (B & (1 << i)) ? P[r][i] : (1. - P[r][i]);
- if (p < EPS) continue;
-
- for (C = 0, i = 0; i < m; i++) {
- if (B & (1 << i)) continue;
-
- for (j = i; j < m && ((B >> j) & 1) == 0; j++)
- if ((A >> j) & 1) { C |= 1 << i; break; }
-
- for (j = i; j >= 0 && ((B >> j) & 1) == 0; j--)
- if ((A >> j) & 1) { C |= 1 << i; break; }
- }
-
- ftab[r][A] += p * f(r+1, C);
- }
-
- return ftab[r][A];
-}
-
-void solve()
-{
- int i, j, r;
- double p;
-
- enforce_r = 999;
- id++;
- for (i = n; i >= 0; i--)
- for (j = 0; j < (1 << m); j++)
- xtab[i][j] = f(i, j);
-
- for (r = 0; r < n; r++) {
- for (i = 0; i < m; i++) R[r][i] = 0.;
-
- enforce_r = r;
- for (enforce_b = 0; enforce_b < (1 << m); enforce_b++) {
- for (p = 1., i = 0; i < m; i++)
- p *= (enforce_b & (1 << i)) ? P[r][i] : (1. - P[r][i]);
- /*if (p < EPS) continue; */
-
- id++;
- p *= f(0, 1);
-
- for (i = 0; i < m; i++)
- if (enforce_b & (1 << i)) R[r][i] += p;
- }
-
- for (i = 0; i < m; i++) R[r][i] /= xtab[0][1];
- }
-
- for (i = 0; i < n; i++) {
- for (j = 0; j < m; j++) printf(j ? " %.6f" : "%.6f", R[i][j]);
- printf("\n");
- }
-}
-
-int main()
-{
- int i, j, t;
-
- id = 42;
- for (scanf("%d", &t); t-- > 0 && scanf("%d %d", &n, &m) == 2;) {
- assert(1 <= n && n <= 5 && 1 <= m && m <= 6);
-
- for (i = 0; i < n; i++)
- for (j = 0; j < m; j++)
- scanf("%lf", &P[i][j]);
-
- solve();
-
- if (t) printf("\n");
- }
-
- return 0;
-}
141 acm.uva.es/10531/temp/p4a.c
View
@@ -1,141 +0,0 @@
-#include <stdio.h>
-#include <assert.h>
-
-#define EPS 1e-10
-
-int fgot[8][1024], enforce_r, enforce_b, id, n, m;
-double P[8][8], R[8][8], ftab[8][1024], xtab[8][1024];
-
-int join(int A, int B)
-{
- int C, i, j, k, u, v, s;
-
- C = 0;
-
- for (i = 0; i < m; i++) {
- if (((A >> (2 * i)) & 3) != 1) continue;
-
- for (j = i; j >= 0 && ((B >> j) & 1) == 0; j--)
- C |= 1 << (2 * j);
-
- for (j = i+1; j < m && ((B >> j) & 1) == 0; j++)
- C |= 1 << (2 * j);
- }
-
- if (C == 0)
- return 0;
-
-printf("join A={");
-for(i=0;i<m;i++)printf(" %d",(A>>(2*i))&3);
-printf(" } B={");
-for(i=0;i<m;i++)printf(" %d",(B>>i)&1);
-printf(" } C0={");
-for(i=0;i<m;i++)printf(" %d",(C>>(2*i))&3);
-printf(" } C={");
-
- for (i = 0, k = 1;;) {
- for (; i < m; i++)
- if (((B >> i) & 1) == 0 && ((C >> (2 * i)) & 3) == 0) break;
- if (i >= m) break;
-
- for (k++; i < m && ((B >> i) & 1) == 0; i++)
- C |= k << (2 * i);
- }
-
- do {
- s = 0;
- for (i = 0; i < m; i++) {
- if (((A>>(2*i))&3)==0) continue;
- for (j = i + 1; j < m; j++) {
- if (((A>>(2*i))&3) != ((A>>(2*j))&3)) continue;
-
- u = ((C>>(2*i))&3); v = ((C>>(2*j))&3);
- if (u == v || u == 0 || v == 0) continue;
- if (u < v) { k = u; u = v; v = k; }
-
- for (k = 0; k < m; k++) {
- if (((C>>(2*k))&3) != u) continue;
- C &= ~(3 << (2*k));
- C |= v << (2*k);
- s++;
- }
- }
- }
-
- for (i = 0; i < m; i++) {
- if (((C>>(2*i))&3)==0) continue;
- for (j = i + 1; j < m; j++) {
- if (((C>>(2*i))&3) != ((C>>(2*j))&3)) continue;
-
- u = ((A>>(2*i))&3); v = ((A>>(2*j))&3);
- if (u == v || u == 0 || v == 0) continue;
- if (u < v) { k = u; u = v; v = k; }
-
- for (k = 0; k < m; k++) {
- if (((A>>(2*k))&3) != u) continue;
- A &= ~(3 << (2*k));
- A |= v << (2*k);
- s++;
- }
- }
- }
- } while (s > 0);
-
-for(i=0;i<m;i++)printf(" %d",(C>>(2*i))&3);
-printf("}\n");
-
- return C;
-}
-
-double f(int r, int A)
-{
- int i, B;
- double p;
-
- if (fgot[r][A] == id) return ftab[r][A];
- fgot[r][A] = id;
-
-printf("f(r=%d, A=%.4X)\n",r,A);
-
- if (r == n) return ftab[r][A] = (((A >> (m - 1)) & 1) ? 1. : 0.);
- if (A == 0) return ftab[r][A] = 0.;
-
- ftab[r][A] = 0.;
- for (B = 0; B < (1 << m); B++) {
- for (p = 1., i = 0; i < m; i++)
- p *= (B & (1 << i)) ? P[r][i] : (1. - P[r][i]);
- if (p < EPS) continue;
-
- ftab[r][A] += p * f(r+1, join(A,B));
- }
-
-printf("f(r=%d, A=%.4X) = %.5f\n",r,A,ftab[r][A]);
- return ftab[r][A];
-}
-
-void solve()
-{
- id++;
- printf("%.5f\n", f(0, 1));
-
-}
-
-int main()
-{
- int i, j, t;
-
- id = 42;
- for (scanf("%d", &t); t-- > 0 && scanf("%d %d", &m, &n) == 2;) {
- assert(1 <= n && n <= 6 && 1 <= m && m <= 5);
-
- for (i = 0; i < m; i++)
- for (j = 0; j < n; j++)
- scanf("%lf", &P[j][i]);
-
- solve();
-
- if (t) printf("\n");
- }
-
- return 0;
-}
140 acm.uva.es/10531/temp/p4b.c
View
@@ -1,140 +0,0 @@
-#include <stdio.h>
-#include <assert.h>
-
-#define EPS 1e-10
-
-int fgot[8][1024], enforce_r, enforce_b, id, n, m;
-double P[8][8], R[8][8], ftab[8][1024], xtab[8][1024];
-
-int jtab[6][1024][32];
-
-int min(int x, int y) { return (x < y) ? x : y; }
-int max(int x, int y) { return (x > y) ? x : y; }
-
-int join(int A, int B)
-{
- int a[8], b[8], c[8], i, j, k, t, s, chg;
-
- for (i = 0; i < m; i++) {
- a[i] = (A >> (2 * i)) & 3;
- b[i] = (B >> i) & 1;
- c[i] = 0;
-
- }
-
-/*printf("join ");
-printf(" a=(");for(i=0;i<m;i++)printf(i?" %d":"%d",a[i]);printf(")");
-printf(" b=(");for(i=0;i<m;i++)printf(i?" %d":"%d",b[i]);printf(")");
- */
- for (i = 0; i < m; i++) {
- if (a[i] != 1) continue;
- for (j = i; j >= 0 && b[j] == 0; j--) c[j] = 1;
- for (j = i; j < m && b[j] == 0; j++) c[j] = 1;
- }
-
- for (i = 0; i < m && c[i] != 1; i++);
- if (i >= m) { /*printf(" => 0\n");*/ return 0;}
-
- for (i = 0, k = 1;;) {
- while (i < m && (b[i] || c[i])) i++;
- if (i >= m) break;
- for (k++; i < m && b[i] == 0; i++) c[i] = k;
- }
-
- do {
- chg = 0;
- for (i = 0; i < m; i++) {
- for (j = i + 1; j < m; j++) {
- if (c[i] != c[j] || c[i] == 0) continue;
- if (a[i] == a[j] || a[i] == 0 || a[j] == 0) continue;
- t = max(a[i], a[j]); s = min(a[i], a[j]);
- for (k = 0; k < m; k++)
- if (a[k] == t) { a[k] = s; chg = 1; }
- }
- }
-
- for (i = 0; i < m; i++) {
- for (j = i + 1; j < m; j++) {
- if (a[i] != a[j] || a[i] == 0) continue;
- if (c[i] == c[j] || c[i] == 0 || c[j] == 0) continue;
- t = max(c[i], c[j]); s = min(c[i], c[j]);
- for (k = 0; k < m; k++)
- if (c[k] == t) { c[k] = s; chg = 1; }
- }
- }
- } while (chg);
-
- for (k = 0, i = 0; i < m; i++)
- k |= c[i] << (2 * i);
-
-/*printf(" c=(");for(i=0;i<m;i++)printf(i?" %d":"%d",c[i]);printf(")");
-printf("\n");*/
-
-/*printf("j m=%d A=%.4X B=%.4X C=%.4X\n",m,A,B,k);*/
-
- return k;
-}
-
-double f(int r, int A)
-{
- int i, B;
- double p;
-
- if (fgot[r][A] == id) return ftab[r][A];
- fgot[r][A] = id;
-
-/*printf("f(r=%d, A=%.4X)\n",r,A);*/
-
- if (r == n) return ftab[r][A] = (((A>>(2*(m-1)))&3)==1) ? 1. : 0.;
- if (A == 0) return ftab[r][A] = 0.;
-
- ftab[r][A] = 0.;
- for (B = 0; B < (1 << m); B++) {
- for (p = 1., i = 0; i < m; i++)
- p *= (B & (1 << i)) ? P[r][i] : (1. - P[r][i]);
- if (p < EPS) continue;
-if(jtab[m][A][B]!=join(A,B)) {
- printf("m=%d A=%.4X b=%.4X jtab=%d join=%d\n",m,A,B,jtab[m][A][B],join(A,B));
- exit(0);
-}
- ftab[r][A] += p * f(r+1, join(A,B));
- }
-
-/*printf("f(r=%d, A=%.4X) = %.5f\n",r,A,ftab[r][A]);*/
- return ftab[r][A];
-}
-
-void solve()
-{
- id++;
- printf("%.5f\n", f(0, 1));
-
-}
-
-int main()
-{
- int i, j, t;
-int k=0;
-t=clock();
-
- for (m = 1; m <= 5; m++)
- for (i = 0; i < (1 << (2 * m)); i++)
- for (j = 0; j < (1 << m); j++)
- {k++;jtab[m][i][j] = join(i, j);}
-printf("[%d] %d\n",clock()-t,k);
-
- id = 42;
- for (scanf("%d", &t); t-- > 0 && scanf("%d %d", &m, &n) == 2;) {
- assert(1 <= n && n <= 6 && 1 <= m && m <= 5);
-
- for (i = 0; i < m; i++)
- for (j = 0; j < n; j++)
- scanf("%lf", &P[j][i]);
-
- solve();
-
- if (t) printf("\n");
- }
-
- return 0;
-}
163 acm.uva.es/10531/temp/p4c.c
View
@@ -1,163 +0,0 @@
-#include <stdio.h>
-#include <assert.h>
-
-#define EPS 1e-10
-
-int fgot[8][1024], enforce_r, enforce_b, id, n, m;
-double P[8][8], R[8][8], ftab[8][1024], xtab[8][1024];
-
-int jtab[6][1024][32];
-
-int min(int x, int y) { return (x < y) ? x : y; }
-int max(int x, int y) { return (x > y) ? x : y; }
-
-int join(int A, int B)
-{
- int a[8], b[8], c[8], i, j, k, t, s, chg;
-
- for (i = 0; i < m; i++) {
- a[i] = (A >> (2 * i)) & 3;
- b[i] = (B >> i) & 1;
- c[i] = 0;
-
- }
-
-/*printf("join ");
-printf(" a=(");for(i=0;i<m;i++)printf(i?" %d":"%d",a[i]);printf(")");
-printf(" b=(");for(i=0;i<m;i++)printf(i?" %d":"%d",b[i]);printf(")");
- */
- for (i = 0; i < m; i++) {
- if (a[i] != 1) continue;
- for (j = i; j >= 0 && b[j] == 0; j--) c[j] = 1;
- for (j = i; j < m && b[j] == 0; j++) c[j] = 1;
- }
-
- for (i = 0; i < m && c[i] != 1; i++);
- if (i >= m) { /*printf(" => 0\n");*/ return 0;}
-
- for (i = 0, k = 1;;) {
- while (i < m && (b[i] || c[i])) i++;
- if (i >= m) break;
- for (k++; i < m && b[i] == 0; i++) c[i] = k;
- }
-
- do {
- chg = 0;
- for (i = 0; i < m; i++) {
- for (j = i + 1; j < m; j++) {
- if (c[i] != c[j] || c[i] == 0) continue;
- if (a[i] == a[j] || a[i] == 0 || a[j] == 0) continue;
- t = max(a[i], a[j]); s = min(a[i], a[j]);
- for (k = 0; k < m; k++)
- if (a[k] == t) { a[k] = s; chg = 1; }
- }
- }
-
- for (i = 0; i < m; i++) {
- for (j = i + 1; j < m; j++) {
- if (a[i] != a[j] || a[i] == 0) continue;
- if (c[i] == c[j] || c[i] == 0 || c[j] == 0) continue;
- t = max(c[i], c[j]); s = min(c[i], c[j]);
- for (k = 0; k < m; k++)
- if (c[k] == t) { c[k] = s; chg = 1; }
- }
- }
- } while (chg);
-
- for (k = 0, i = 0; i < m; i++)
- k |= c[i] << (2 * i);
-
-/*printf(" c=(");for(i=0;i<m;i++)printf(i?" %d":"%d",c[i]);printf(")");
-printf("\n");*/
-
-/*printf("j m=%d A=%.4X B=%.4X C=%.4X\n",m,A,B,k);*/
-
- return k;
-}
-
-double f(int r, int A)
-{
- int i, B;
- double p;
-
- if (fgot[r][A] == id) return ftab[r][A];
- fgot[r][A] = id;
-
-/*printf("f(r=%d, A=%.4X)\n",r,A);*/
-
- if (r == n) return ftab[r][A] = (((A>>(2*(m-1)))&3)==1) ? 1. : 0.;
- if (A == 0) return ftab[r][A] = 0.;
-
- if (enforce_r == r)
- return ftab[r][A] = f(r+1, jtab[m][A][enforce_b]);
-
- ftab[r][A] = 0.;
- for (B = 0; B < (1 << m); B++) {
- for (p = 1., i = 0; i < m; i++)
- p *= (B & (1 << i)) ? P[r][i] : (1. - P[r][i]);
- if (p < EPS) continue;
- ftab[r][A] += p * f(r+1, jtab[m][A][B]);
- }
-
-/*printf("f(r=%d, A=%.4X) = %.5f\n",r,A,ftab[r][A]);*/
- return ftab[r][A];
-}
-
-void solve()
-{
- int i, j, r;
- double p, q;
-
- id++;
- enforce_r = -1;
- q = f(0, 1);
-
- for (r = 0; r < n; r++) {
- for (i = 0; i < m; i++) R[r][i] = 0.;
-
- enforce_r = r;
- for (enforce_b = 0; enforce_b < (1 << m); enforce_b++) {
- for (p = 1., i = 0; i < m; i++)
- p *= (enforce_b & (1 << i)) ? P[r][i] : (1. - P[r][i]);
- if (p < EPS) continue;
-
- id++;
- p *= f(0, 1);
-
- for (i = 0; i < m; i++)
- if (enforce_b & (1 << i)) R[r][i] += p;
- }
-
- for (i = 0; i < m; i++) R[r][i] /= q;
- }
-
- for (i = 0; i < m; i++) {
- for (j = 0; j < n; j++) printf(j ? " %.6f" : "%.6f", R[j][i]);
- printf("\n");
- }
-}
-
-int main()
-{
- int i, j, t;
-
- for (m = 1; m <= 5; m++)
- for (i = 0; i < (1 << (2 * m)); i++)
- for (j = 0; j < (1 << m); j++)
- jtab[m][i][j] = join(i, j);
-
- id = 42;
- for (scanf("%d", &t); t-- > 0 && scanf("%d %d", &m, &n) == 2;) {
- assert(1 <= n && n <= 6 && 1 <= m && m <= 5);
-
- for (i = 0; i < m; i++)
- for (j = 0; j < n; j++)
- scanf("%lf", &P[j][i]);
-
- solve();
-
- if (t) printf("\n");
- }
-
- return 0;
-}
24 acm.uva.es/10590/temp/p1.cpp
View
@@ -1,24 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-
-#define M 256
-
-unsigned long long f[M][M];
-
-int main()
-{
- memset(f, 0, sizeof(f));
-
- f[0][0] = 1;
-
- for (int k = 1; k < M; k++)
- for (int n = 0; n < M; n++) {
- f[k][n] = f[k-1][n];
- if (n >= k) f[k][n] += f[k][n-k];
- }
-
- for (int n = 0; n < M; n++)
- printf("%5d %llu\n", n, f[M-1][n]);
-
- return 0;
-}
93 acm.uva.es/10619/temp/p1.c
View
@@ -1,93 +0,0 @@
-#include <stdio.h>
-
-#define INF 0x1FFFFFFF
-#define MAX 100001
-
-int x[MAX], y[MAX], xmy[MAX], xpy[MAX], n;
-
-int cmpm(const void *p, const void *q)
-{
- int i = *(int *)p, j = *(int *)q, k;
- k = ((x[i] - y[i]) - (x[j] - y[j]));
- return (k != 0) ? k : (x[i] - x[j]);
-}
-
-int cmpp(const void *p, const void *q)
-{
- int i = *(int *)p, j = *(int *)q, k;
- k = ((x[i] + y[i]) - (x[j] + y[j]));
- return (k != 0) ? k : 0;
-}
-
-int check(int t)
-{
- int i, j, k, a, b;
-
-printf("check(t=%d):\n",t);
-
-for(i=0;i<n;i++)
- printf("(%d,%d): R=%d\n", x[xpy[i]], y[xpy[i]], x[xpy[i]] + y[xpy[i]] - t);
-for(i=0;i<n;i++)
- printf("(%d,%d): L=%d\n", x[xmy[i]], y[xmy[i]], x[xmy[i]] - y[xmy[i]] + t);
-
- i = xpy[0];
-printf("first:(%d,%d) R=%d\n", x[i],y[i], x[i]+y[i]-t);
-
- i = x[i] + y[i] - t;
-printf("L'>%5d\n",i);
-
- for (i = k = 0; i < n;) {
-/* L < b
-*/
- k++;
- printf("left wing: i=%d (%d,%d) R=%d\n",
- i, x[xpy[i]], y[xpy[i]],
- x[xpy[i]] + y[xpy[i]] - t);
-
- a = x[xpy[i]] + y[xpy[i]] - t;
- while (i < n && (
-
- k++;
- }
-
-printf("Need: %d\n",k);
-
-
-}
-
-/* (x',y')
-projection of (x,y) onto y=t: (x,y) /
-R = x - (t - y) = x + y - t / \ /
-L = x + (t - y) = x - y + t --y=t--L-----------R-------
- L'
-t fixed;
-
-R = (x+y) - t
-R = (x'-y') + t
-
-2R - (x+y) = (x'-y')
-
-*/
-
-
-int main()
-{
- int i, c, t, m;
-
- for (scanf("%d", &t), c = 1; c <= t && scanf("%d %d", &n, &m); c++) {
- for (i = 0; i < n; i++)
- scanf("%d %d", &y[i], &x[i]);
-
- for (i = 0; i < n; i++)
- xmy[i] = xpy[i] = i;
- qsort(xmy, n, sizeof(xmy[0]), &cmpm);
- qsort(xpy, n, sizeof(xpy[0]), &cmpp);
-
- check(-2);
-break;
-
-
- }
-
- return 0;
-}
69 acm.uva.es/10619/temp/p2.c
View
@@ -1,69 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#define INF 0x1FFFFFFF
-
-typedef struct { int x, y; } pt_t;
-pt_t p[100001];
-int n;
-
-int cmp(const void *p, const void *q)
-{
- pt_t *a = (pt_t *)p, *b = (pt_t *)q;
- int k = (a->x - a->y) - (b->x - b->y);
- return (k != 0) ? k : 0;
-}
-
-int check(int t)
-{
- int i, j, k, u;
-
-printf("check(t=%d):\n",t);
-for (i = 0; i < n; i++)
- printf("[%d,%d]\n", p[i].x-p[i].y+t, p[i].x+p[i].y-t);
-
- for (i = k = 0, u = -INF;;) {
- while (i < n && (p[i].x - p[i].y + t) <= u) i++;
- if (i >= n) break;
- u = p[i].x + p[i].y - t;
- k++;
- }
-
-printf("<<%d>>\n\n",k);
-
-}
-
-/*
-(x,y) -> [x-y+t,x+y-t],t
-
- (x',y')
-projection of (x,y) onto y=t: (x,y) /
-L = x + (t - y) = x - y + t / \ /
-R = x - (t - y) = x + y - t --y=t--L-----------R-------
- L'
-t fixed;
-
-R = (x+y) - t
-R = (x'-y') + t
-
-2R - (x+y) = (x'-y')
-
-*/
-
-
-int main()
-{
- int i, c, t, m;
-
- for (scanf("%d", &t), c = 1; c <= t && scanf("%d %d", &n, &m); c++) {
- for (i = 0; i < n; i++)
- scanf("%d %d", &p[i].y, &p[i].x);
- qsort(p, n, sizeof(p[0]), &cmp);
-
- check(-2);
- check(-1);
-break;
- }
-
- return 0;
-}
68 acm.uva.es/10619/temp/p3.c
View
@@ -1,68 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#define INF 0x1FFFFFFF
-
-typedef struct { int x, y; } pt_t;
-pt_t p[100001];
-int n;
-
-int cmp(const void *p, const void *q)
-{
- pt_t *a = (pt_t *)p, *b = (pt_t *)q;
- int k = (a->x - a->y) - (b->x - b->y);
- return (k != 0) ? k : 0;
-}
-
-int check(int t)
-{
- int i, j, k, u;
-
- for (i = k = 0, u = -INF;; k++) {
- while (i < n && (p[i].x - p[i].y + t) <= u) i++;
- if (i >= n) break;
-
- j = p[i].x - p[i].y + t;
- u = p[i].x + p[i].y - t;
- for (i++; i < n && (p[i].x - p[i].y + t) == j; i++)
- if ((p[i].x + p[i].y - t) < u) u = p[i].x + p[i].y - t;
- }
-
- return k;
-}
-
-int main()
-{
- int a, b, i, m, s, t;
-
- for (scanf("%d", &t), s = 1; s <= t && scanf("%d %d", &n, &m); s++) {
- for (i = 0; i < n; i++)
- scanf("%d %d", &p[i].y, &p[i].x);
- qsort(p, n, sizeof(p[0]), &cmp);
-
- for (a = p[i = 0].y; i < n; i++)
- if (p[i].y < a) a = p[i].y;
- b = (p[0].x + p[0].y - p[n-1].x + p[n-1].y) / 2 - 10;
-
-printf("a=%d b=%d\n",a,b);
-
-for(i=a;i>=b;i--)
- printf("t=%-3d %-5d\n", i, check(i));
-
- while (a > b) {
- i = (a + b + 1) / 2;
- if (check(i) > m)
- a = i - 1;
- else
- b = i;
- }
-printf("m=%d a=%d b=%d\n",m,a,b);
-
- printf("Case %d: %d\n", s, a);
-
-printf("[%d]\n\n",a);
-
- }
-
- return 0;
-}
67 acm.uva.es/10619/temp/p4.c
View
@@ -1,67 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-typedef struct { int x, y; } pt_t;
-pt_t p[100001];
-int n;
-
-int cmp(const void *p, const void *q)
-{
- pt_t *a = (pt_t *)p, *b = (pt_t *)q;
- int k = (a->x - a->y) - (b->x - b->y);
- return (k != 0) ? k : 0;
-}
-
-int check(int t)
-{
- int i, j, k, u;
-
-printf("check(t=%d):\n",t);
-for (i = 0; i < n; i++)
- printf("[%d,%d]\n", p[i].x-p[i].y+t, p[i].x+p[i].y-t);
-printf("\n");
-
- for (i = k = 0, u = -0x3FFFFFFF;; k++) {
- while (i < n && (p[i].x - p[i].y + t) <= u) i++;
- if (i >= n) break;
-
- j = p[i].x - p[i].y + t;
- u = p[i].x + p[i].y - t;
- for (i++; i < n && (p[i].x - p[i].y + t) == j; i++)
- if ((p[i].x + p[i].y - t) < u) u = p[i].x + p[i].y - t;
- }
-
- return k;
-}
-
-int main()
-{
- int a, b, i, m, s, t;
-
- for (scanf("%d", &t), s = 1; s <= t && scanf("%d %d", &n, &m) == 2; s++) {
- for (i = 0; i < n; i++)
- scanf("%d %d", &p[i].y, &p[i].x);
- qsort(p, n, sizeof(p[0]), &cmp);
-
- for (a = p[i = 0].y; i < n; i++)
- if (p[i].y < a) a = p[i].y;
-/* b = (p[0].x + p[0].y - p[n-1].x + p[n-1].y) / 2 - 10;*/
- b = -10000000;
-
-printf("a=%d b=%d m=%d\n",a,b,m);
-printf("f(a)=%d\n",check(a));
-break;
-
- while (a > b) {
- i = (a + b + 1) / 2;
- if (check(i) > m)
- a = i - 1;
- else
- b = i;
- }
-
- printf("Case %d: %d\n", s, a);
- }
-
- return 0;
-}
23 acm.uva.es/10623/temp/p1.c
View
@@ -1,23 +0,0 @@
-#include <stdio.h>
-
-int f(int e, int c, int t)
-{
- if (t > 0)
- return f(e, c, 0) + 6 * (c + e) * t + 3 * t * t - 3 * t + ((e == 0 && c == 0) ? 1 : 0);
- else if (e > 0)
- return f(0, c, 0) + 4 * c * e + 2 * e * e - 2 * e + ((c == 0) ? 1 : 0);
- else if (c > 0)
- return (c * c - c + 2);
- else
- return 1;
-}
-
-int main()
-{
- int e, c, t;
-
- while (scanf("%d %d %d", &e, &c, &t) == 3)
- printf("%d\n", f(e, c, t));
-
- return 0;
-}
19 acm.uva.es/10623/temp/p2.c
View
@@ -1,19 +0,0 @@
-#include <stdio.h>
-
-int f(int e, int c, int t)
-{
- int r = (c == 0) ? 1 : (c * c - c + 2);
- if (e > 0) r += (2 * c + e - 1) * e * 2 + ((r == 1) ? 1 : 0);
- if (t > 0) r += (2 * (c + e) + t - 1) * t * 3 + ((r == 1) ? 1 : 0);
- return r;
-}
-
-int main()
-{
- int e, c, t;
-
- while (scanf("%d %d %d", &e, &c, &t) == 3)
- printf("%d\n", f(e, c, t));
-
- return 0;
-}
48 acm.uva.es/10643/temp/x.c
View
@@ -1,48 +0,0 @@
-#include <stdio.h>
-
-/* Let G(n) be a tree on n vertices, with out-degree of each its
- vertex limited to {0,2} */
-
-/* Returns the number of different G(n) trees */
-int g(int n)
-{
- int s, k;
-
- if (n == 0 || n == 1)
- return 1;
-
- if (n < 0 || ((n % 2) == 0))
- return 0;
-
- for (s = 0, k = 0; k < n; k++)
- s += g(k) * g(n - k - 1);
-
- return s;
-}
-
-/* Returns the number of ordered forests of G(i) trees on m vertices */
-int f(int m)
-{
- int s, k;
-
- if (m < 0)
- return 0;
-
- if (m == 0)
- return 1;
-
- for (s = 0, k = 1; k <= m; k++)
- s += g(k) * f(m - k);
-
- return s;
-}
-
-int main()
-{
- int n;
-
- while (scanf("%d", &n) == 1)
- printf("f(%d) = %d, g(%d) = %d\n", n, f(n), n, g(n));
-
- return 0;
-}
73 acm.uva.es/10643/temp/y.c
View
@@ -1,73 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-
-#define NDIG 160
-
-typedef struct {
- int n, d[NDIG];
-} num_t;
-
-void set(num_t *z, int a)
-{
- memset(z, 0, sizeof(num_t));
- z->d[0] = a;
- z->n = (a == 0) ? 0 : 1;
-}
-
-static void muladd(num_t *z, num_t *x, num_t *y)
-{
- register int i, j, c;
-
- if (z->n < (c = x->n + y->n + 4)) {
- for (i = z->n; i < c; i++)
- z->d[i] = 0;
- z->n = c;
- }
-
- for (i = 0; i < x->n; i++) {
- for (j = 0, c = 0; j < y->n; j++, c /= 10)
- z->d[i+j] = (c += z->d[i+j] + x->d[i] * y->d[j]) % 10;
-
- for (j += i; c > 0; j++, c /= 10)
- z->d[j] = (c += z->d[j]) % 10;
- }
-
- while (z->n > 0 && z->d[z->n - 1] == 0)
- z->n--;
-}
-
-char *fmt(num_t *x)
-{
- static char buf[1024];
- int i, j;
-
- if (x->n <= 0)
- return "0";
-
- for (i = x->n - 1; i > 0 && x->d[i] == 0; i--);
-
- for (j = 0; i >= 0;)
- buf[j++] = x->d[i--] + '0';
- buf[j] = '\0';
-
- return buf;
-}
-
-int main()
-{
- static num_t f[512], g[512];
- int i, k, a, t;
-
- memset(g, 0, sizeof(g));
- for (set(&g[0], 1), set(&g[1], 1), k = 3; k <= 500; k += 2)
- for (i = 0; i < k; i++) muladd(&g[k], &g[i], &g[k - i - 1]);
-
- memset(f, 0, sizeof(f));
- for (set(&f[0], 1), k = 1; k <= 500; k++)
- for (i = 1; i <= k; i++) muladd(&f[k], &g[i], &f[k - i]);
-
- for (scanf("%d", &t), k = 1; k <= t && scanf("%d", &a) == 1; k++)
- printf("Case %d: %s\n", k, fmt(&f[a]));
-
- return 0;
-}
30 acm.uva.es/10722/temp1/p1.c
View
@@ -1,30 +0,0 @@
-#include <stdio.h>
-
-
-
-int main()
-{
- static int tab[128][128], b, n;
- register int i, k, s;
-
- while (scanf("%d %d", &b, &n) == 2 && b > 0) {
- for (tab[1][0] = 0, i = 1; i < b; i++)
- tab[1][i] = 1;
-
- for (k = 1, s = 0; k <= n;) {
- for (i = 0, s = 0; i < b; i++)
- s += tab[k][i];
-
- if (k++ == n)
- break;
-
- for (i = 0; i < b; i++)
- tab[k][i] = s;
- tab[k][3] -= tab[k - 1][1];
- }
-
- printf("%d\n", s);
- }
-
- return 0;
-}
97 acm.uva.es/10722/temp1/p2.c
View
@@ -1,97 +0,0 @@
-#include <stdio.h>
-
-#define NLIMBS 24
-
-typedef unsigned long u_int32_t;
-typedef u_int32_t num_t[NLIMBS];
-
-void set(num_t x, u_int32_t y)
-{
- int i;
-
- for (x[0] = y, i = 0; i < NLIMBS; i++)
- x[i] = 0;
-}
-
-void add(num_t x, num_t y)
-{
- int i;
- u_int32_t c;
-
- for (i = 0, c = 0; i < NLIMBS; i++, c >>= 31) {
- c += x[i] + y[i];
- x[i] = c & 0x7FFFFFFF;
- }
-}
-
-void sub(num_t x, num_t y)
-{
- int i;
- u_int32_t c;
-
- for (i = 0, c = 1; i < NLIMBS; i++, c >>= 31) {
- c += x[i] + (y[i] ^ 0x7FFFFFFF);
- x[i] = c & 0x7FFFFFFF;
- }
-}
-
-void print(num_t x)
-{
- static char buf[1024], buf2[1024];
- unsigned long long r;
- int i;
- char *s;
-
- for (s = buf;;) {
- for (i = NLIMBS - 1, r = 0; i >= 0; i--) {
- r = (r << 31) | (unsigned long long)x[i];
- x[i] = (u_int32_t)(r / 1000000000ULL);
- r %= 1000000000ULL;
- }
-
- if (s == buf)
- sprintf(s, "%u", (unsigned)r);
- else
- sprintf(s, "%.9u", (unsigned)r);
- while (*s) s++;
-
- for (i = 0; i < NLIMBS; i++)
- if (x[i]) break;
-
- if (i >= NLIMBS)
- break;
- }
-
- for (i = 0; s-- > buf;)
- buf2[i++] = *s;
- buf2[i] = '\0';
-
- printf("%s\n", buf2);
-}
-
-int main()
-{
- static int tab[128][128], b, n;
- register int i, k, s;
-
- while (scanf("%d %d", &b, &n) == 2 && b > 0) {
- for (tab[1][0] = 0, i = 1; i < b; i++)
- tab[1][i] = 1;
-
- for (k = 1, s = 0; k <= n;) {
- for (i = 0, s = 0; i < b; i++)
- s += tab[k][i];
-
- if (k++ == n)
- break;
-
- for (i = 0; i < b; i++)
- tab[k][i] = s;
- tab[k][3] -= tab[k - 1][1];
- }
-
- printf("%d\n", s);
- }
-
- return 0;
-}
105 acm.uva.es/10722/temp1/p3.c
View
@@ -1,105 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-
-#define NLIMBS 24
-
-typedef unsigned long u_int32_t;
-typedef u_int32_t num_t[NLIMBS];
-
-void set(num_t x, u_int32_t y)
-{
- int i;
-
- for (x[0] = y, i = 1; i < NLIMBS; i++)
- x[i] = 0;
-}
-
-void add(num_t x, num_t y)
-{
- int i;
- u_int32_t c;
-
- for (i = 0, c = 0; i < NLIMBS; i++, c >>= 31) {
- c += x[i] + y[i];
- x[i] = c & 0x7FFFFFFF;
- }
-}
-
-void sub(num_t x, num_t y)
-{
- int i;
- u_int32_t c;
-
- for (i = 0, c = 1; i < NLIMBS; i++, c >>= 31) {
- c += x[i] + (y[i] ^ 0x7FFFFFFF);
- x[i] = c & 0x7FFFFFFF;
- }
-}
-
-void print(num_t x)
-{
- static char buf[1024], buf2[1024];
- unsigned long long r;
- int i, k;
- char *s;
-
- for (s = buf;;) {
- for (i = NLIMBS - 1, r = 0; i >= 0; i--) {
- r = (r << 31) | (unsigned long long)x[i];
- x[i] = (u_int32_t)(r / 1000000000ULL);
- r %= 1000000000ULL;
- }
-
- for (k = 0, i = r; k < 9; k++, i /= 10)
- *s++ = (i % 10) + '0';
-
- for (i = 0; i < NLIMBS; i++)
- if (x[i]) break;
-
- if (i >= NLIMBS)
- break;
- }
-
- for (s--; s > buf && *s == '0'; s--);
-
- for (i = 0; s >= buf;)
- buf2[i++] = *s--;
- buf2[i] = '\0';
-
- printf("%s\n", buf2);
-}
-
-int main()
-{
- static num_t buf1[256], buf2[256], s;
- static int b, n;
- register int i, k;
- register num_t *tab, *tabnext;
-
- while (scanf("%d %d", &b, &n) == 2 && b > 0) {
- tab = buf1;
- tabnext = buf2;
-
- for (set(tab[0], 0), i = 1; i < b; i++)
- set(tab[i], 1);
-
- for (k = 1; k <= n;) {
- for (set(s, 0), i = 0; i < b; i++)
- add(s, tab[i]);
-
- if (k++ == n)
- break;
-
- for (i = 0; i < b; i++)
- memcpy(tabnext[i], s, sizeof(num_t));
- sub(tabnext[3], tab[1]);
-
- tab = tabnext;
- tabnext = (tabnext == buf1) ? buf2 : buf1;
- }
-
- print(s);
- }
-
- return 0;
-}
128 acm.uva.es/10722/temp1/p4.c
View
@@ -1,128 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define NLIMBS 24
-
-typedef unsigned long u_int32_t;
-typedef u_int32_t num_t[NLIMBS];
-
-static num_t result[130][128];
-static char *result_s[130][128];
-
-void set(num_t x, u_int32_t y)
-{
- int i;
-
- for (x[0] = y, i = 1; i < NLIMBS; i++)
- x[i] = 0;
-}
-
-void add(num_t x, num_t y)
-{
- int i;
- u_int32_t c;
-
- for (i = 0, c = 0; i < NLIMBS; i++, c >>= 31) {
- c += x[i] + y[i];
- x[i] = c & 0x7FFFFFFF;
- }
-}
-
-void sub(num_t x, num_t y)
-{
- int i;
- u_int32_t c;
-
- for (i = 0, c = 1; i < NLIMBS; i++, c >>= 31) {
- c += x[i] + (y[i] ^ 0x7FFFFFFF);
- x[i] = c & 0x7FFFFFFF;
- }
-}
-
-char *format(num_t x)
-{
- static char buf[1024], buf2[1024];
- unsigned long long r;
- int i, k;
- char *s;
-
- for (s = buf;;) {
- for (i = NLIMBS - 1, r = 0; i >= 0; i--) {
- r = (r << 31) | (unsigned long long)x[i];
- x[i] = (u_int32_t)(r / 1000000000ULL);
- r %= 1000000000ULL;
- }
-
- for (k = 0, i = r; k < 9; k++, i /= 10)
- *s++ = (i % 10) + '0';
-
- for (i = 0; i < NLIMBS; i++)
- if (x[i]) break;
-
- if (i >= NLIMBS)
- break;
- }
-
- for (s--; s > buf && *s == '0'; s--);
-
- for (i = 0; s >= buf;)
- buf2[i++] = *s--;
- buf2[i] = '\0';
-
- s = (char *)malloc(i + 1);
- strcpy(s, buf2);
-
- return s;
-}
-
-static void compute(int b)
-{
- static num_t buf1[256], buf2[256], s;
- register int i, k;
- register num_t *tab, *tabnext;
-
- tab = buf1;
- tabnext = buf2;
-
- for (set(tab[0], 0), i = 1; i < b; i++)
- set(tab[i], 1);
-
- for (k = 1;;) {
- for (set(s, 0), i = 0; i < b; i++)
- add(s, tab[i]);
-
- memcpy(result[b][k], s, sizeof(num_t));
-
- if (++k > 100)
- break;
-
- for (i = 0; i < b; i++)
- memcpy(tabnext[i], s, sizeof(num_t));
- sub(tabnext[3], tab[1]);
-
- tab = tabnext;
- tabnext = (tabnext == buf1) ? buf2 : buf1;
- }
-}
-
-int main()
-{
- static int computed[128];
- int b, n;
-
- memset(computed, 0, sizeof(computed));
- memset(result_s, 0, sizeof(result_s));
-
- while (scanf("%d %d", &b, &n) == 2 && b > 0) {
- if (!computed[b])
- compute(b);
-
- if (result_s[b][n] == NULL)
- result_s[b][n] = format(result[b][n]);
-
- printf("%s\n", result_s[b][n]);
- }
-
- return 0;
-}
129 acm.uva.es/10755/temp/p1.c
View
@@ -1,129 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-
-int n1, n2, n3;
-long long arr[32][32][32];
-long long xyz_sum[32][32][32];
-long long yz_sum[32][32][32];
-long long z_sum[32][32][32];
-
-/*
- 7 (x)
- /
- +--------+
- / / / /|
- *--+--+--+----->
- | | | |/| (z)
- +--+--+--+ |
- | | | |/|
- +--+--+--+ |
- | | | |/
- +--+--+--+
- |
- v (y)
-*/
-
-long long solve()
-{
- static long long sub[32], r;
- int i, j, k, x1, x2, y1, y2;
- long long s;
-
- scanf("%d %d %d", &n1, &n2, &n3);
- memset(arr, 0, sizeof(arr));
-
- for (i = 1; i <= n1; i++)
- for (j = 1; j <= n2; j++)
- for (k = 1; k <= n3; k++)
- scanf("%lld", &arr[i][j][k]);
-
- memset(z_sum, 0, sizeof(z_sum));
- for (i = 1; i <= n1; i++)
- for (j = 1; j <= n2; j++)
- for (z_sum[i][j][0] = 0, k = 1; k <= n3; k++)
- z_sum[i][j][k] = z_sum[i][j][k - 1] + arr[i][j][k];
-
-for(i=1;i<=n1;i++) {
- printf("z_sum[x=%d]:\n",i);
- for(j=1;j<=n2;j++){
- for(k=1;k<=n3;k++)printf("%lld ",z_sum[i][j][k]);
- printf("\n");
- }}
-
- memset(yz_sum, 0, sizeof(yz_sum));
- for (i = 1; i <= n1; i++)
- for (j = 1; j <= n2; j++)
- for (k = 1; k <= n3; k++)
- yz_sum[i][j][k] = yz_sum[i][j - 1][k] + z_sum[i][j][k];
-
-for(i=1;i<=n1;i++) {
- printf("yz_sum[x=%d]:\n",i);
- for(j=1;j<=n2;j++){
- for(k=1;k<=n3;k++)printf("%lld ",yz_sum[i][j][k]);
- printf("\n");
- }}
-
-
- memset(xyz_sum, 0, sizeof(xyz_sum));
- for (i = 1; i <= n1; i++)
- for (j = 1; j <= n2; j++)
- for (k = 1; k <= n2; k++)
- xyz_sum[i][j][k] = xyz_sum[i - 1][j][k] + yz_sum[i][j][k];
-
-for(i=1;i<=n1;i++) {
- printf("xyz_sum[x=%d]:\n",i);
- for(j=1;j<=n2;j++){
- for(k=1;k<=n3;k++)printf("%lld ",xyz_sum[i][j][k]);
- printf("\n");
- }}
-
- for (r = arr[1][1][1], i = 1; i <= n1; i++)
- for (j = 1; j <= n2; j++)
- for (k = 1; k <= n3; k++)
- if (arr[i][j][k] > r) r = arr[i][j][k];
-
-printf("solving\n");
- for (x1 = 0; x1 < n1; x1++) {
- for (x2 = x1 + 1; x2 <= n1; x2++) {
- for (y1 = 0; y1 < n2; y1++) {
- for (y2 = y1 + 1; y2 <= n2; y2++) {
-
-/*
- for (sub[0] = 0, i = 1; i <= n3; i++)
- sub[i] = xyz_sum[x2][y2][i] - xyz_sum[x1][y1][i - 1];
-*/
-
-sub[0] = 0;
-for (i = 1; i <= n3; i++)
- sub[i] = xyz_sum[x2][y2][i]
- - xyz_sum[x1][y2][i] - xyz_sum[x2][y1][i] - xyz_sum[x2][y2][i - 1]
- + xyz_sum[x1][y1][i] + xyz_sum[x1][y2][i - 1] + xyz_sum[x2][y1][i - 1]
- - xyz_sum[x1][y1][i - 1];
-
-printf("x=%d..%d y=%d..%d slices:",x1,x2,y1,y2);
-for(i=1;i<=n3;i++)printf(" %lld",sub[i]);printf("\n");
-
- for (s = 0, i = 1; i <= n3; i++) {
- if ((s += sub[i]) < 0) {
- s = 0;
- } else if (s > r) {
- r = s;
- }
- }
- }
- }
- }
- }
-
- return r;
-}
-
-int main()
-{
- int t;
-
- for (scanf("%d", &t); t-- > 0;)
- printf("%lld\n%s", solve(), t ? "\n" : "");
-
- return 0;
-}
78 acm.uva.es/10755/temp/p2.c
View
@@ -1,78 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-
-int n1, n2, n3;
-long long arr[32][32][32];
-long long xyz_sum[32][32][32];
-long long yz_sum[32][32][32];
-long long z_sum[32][32][32];
-
-long long solve()
-{
- int i, j, k, x1, x2, y1, y2;
- long long r, s;
-
- scanf("%d %d %d", &n1, &n2, &n3);
- memset(arr, 0, sizeof(arr));
-
- for (i = 1; i <= n1; i++)
- for (j = 1; j <= n2; j++)
- for (k = 1; k <= n3; k++)
- scanf("%lld", &arr[i][j][k]);
-
- memset(z_sum, 0, sizeof(z_sum));
- for (i = 1; i <= n1; i++)
- for (j = 1; j <= n2; j++)
- for (z_sum[i][j][0] = 0, k = 1; k <= n3; k++)
- z_sum[i][j][k] = z_sum[i][j][k - 1] + arr[i][j][k];
-
- memset(yz_sum, 0, sizeof(yz_sum));
- for