about summary refs log tree commit diff
path: root/codechef/xypizq.lisp
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-01-14 20:41:09 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2019-01-14 20:41:09 +0700
commitce56bd193a7c8c6437443227cd3abb51134e3e7a (patch)
tree590c003d9f99e9912e0618a8c77d73ed2b481d20 /codechef/xypizq.lisp
parentbf538954817e568322c83030dd2fbc688a3ee13d (diff)
downloadcp-ce56bd193a7c8c6437443227cd3abb51134e3e7a.tar.gz
At least I managed to stay in top 10%
Diffstat (limited to 'codechef/xypizq.lisp')
-rw-r--r--codechef/xypizq.lisp8
1 files changed, 8 insertions, 0 deletions
diff --git a/codechef/xypizq.lisp b/codechef/xypizq.lisp
new file mode 100644
index 0000000..3d6f14c
--- /dev/null
+++ b/codechef/xypizq.lisp
@@ -0,0 +1,8 @@
+(defun xypizq (N q x y z)
+  (cond ((= q 1) (if (= x z) (/ x (1+ (* N 2))) (- 1 (xypizq N 1 z y z))))
+        ((= q 3) (xypizq N 1 z y x))
+        (t (- 1 (/ (* y 2) (1+ (* N 2)))))))
+
+(dotimes (tests (read))
+  (let ((result (xypizq (read) (read) (read) (read) (read))))
+    (format t "~a ~a~&" (numerator result) (denominator result))))