diff options
author | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2018-10-20 11:27:47 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <vn.mcsinyx@gmail.com> | 2018-10-20 11:27:47 +0700 |
commit | 4c5ed94087a691ce47882786aea64f7b5bf3c130 (patch) | |
tree | 6ebb9374e9c9e1d867659a1de166fbe8f6481b19 /codechef/qabc.lisp | |
parent | 662168dbd56cbeba35bea782d580b0f7cc9a3ac2 (diff) | |
download | cp-4c5ed94087a691ce47882786aea64f7b5bf3c130.tar.gz |
Bon appétit
Diffstat (limited to 'codechef/qabc.lisp')
-rw-r--r-- | codechef/qabc.lisp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/codechef/qabc.lisp b/codechef/qabc.lisp new file mode 100644 index 0000000..7c9619b --- /dev/null +++ b/codechef/qabc.lisp @@ -0,0 +1,18 @@ +(defun read-list (str) + (read-from-string (concatenate 'string "(" str ")"))) + +(defun qabc (seq n &optional (a1 0) (a2 0)) + (if (< n 3) + (if (every #'zerop (mapcar #'- (list a1 a2) seq)) "TAK" "NIE") + (let ((a0 (- (first seq) a1))) + (if (< a0 0) + "NIE" + (qabc (rest seq) (1- n) (+ a2 (* a0 2)) (* a0 3)))))) + +(let ((tests (read))) + (dotimes (i tests) + (let* ((n (read)) + (a (read-list (read-line))) + (b (read-list (read-line)))) + (princ (qabc (mapcar #'- b a) n)) + (fresh-line)))) |