From 55f65cac5d65f022893879b3cdc14aa96cf38024 Mon Sep 17 00:00:00 2001 From: Ankur Sundara Date: Sat, 11 Mar 2017 00:30:58 -0600 Subject: [PATCH 1/4] Create generator.py --- library/generator.py | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 library/generator.py diff --git a/library/generator.py b/library/generator.py new file mode 100644 index 0000000..ea66ed5 --- /dev/null +++ b/library/generator.py @@ -0,0 +1,11 @@ +import random +C = input() + +if C==1: + print 1 +elif C==2: + print 2 +elif C==3 or C==4: + print random.randint(3, 100) +else: + print random.randint(2**(C**3-1), 2**(C**3)) From 41cf2ab68a09a024d24c4cc48033f39135749382 Mon Sep 17 00:00:00 2001 From: Ankur Sundara Date: Sat, 11 Mar 2017 00:32:58 -0600 Subject: [PATCH 2/4] Create grader.py --- library/grader.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 library/grader.py diff --git a/library/grader.py b/library/grader.py new file mode 100644 index 0000000..fcccfc1 --- /dev/null +++ b/library/grader.py @@ -0,0 +1,39 @@ +x = input() + +mat = [[0,0,1,0],[0,1,0,1],[1,0,2,0],[0,2,0,1]] +mod = 10**9+7 + +def egcd(a, b): + if a == 0: + return (b, 0, 1) + else: + g, y, x = egcd(b % a, a) + return (g, x - (b // a) * y, y) + +def modinv(a, m): + g, x, y = egcd(a, m) + if g != 1: + raise Exception('modular inverse does not exist') + else: + return x % m + +def matmult(mtx_a, mtx_b, mod): + tpos_b = zip( *mtx_b) + rtn = [[ sum( ea*eb for ea,eb in zip(a,b))%mod for b in tpos_b] for a in mtx_a] + return rtn + +def trace(A): + return sum(A[j][j] for j in range(len(A))) + +def matpow(A, p): + ret = A + for bit in bin(p)[3:]: + ret = matmult(ret, ret, mod) + if bit=='1': + ret = matmult(ret, A, mod) + return ret + +inv4 = modinv(4, mod) +ans = trace(matpow(mat, x))%mod +ans = (ans * inv4)% mod +print ans From 8802d17a24b1cb6298f1bb8bdc13be5d0c2f15b3 Mon Sep 17 00:00:00 2001 From: Ankur Sundara Date: Sat, 11 Mar 2017 00:34:41 -0600 Subject: [PATCH 3/4] Fix grader.py --- library/grader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/grader.py b/library/grader.py index fcccfc1..b98e56c 100644 --- a/library/grader.py +++ b/library/grader.py @@ -1,4 +1,4 @@ -x = input() +x = input() + 1 mat = [[0,0,1,0],[0,1,0,1],[1,0,2,0],[0,2,0,1]] mod = 10**9+7 From fd1421bff5dc56c05f456373dfe588530e7128c6 Mon Sep 17 00:00:00 2001 From: Ankur Sundara Date: Sat, 11 Mar 2017 00:38:01 -0600 Subject: [PATCH 4/4] Update description.md --- library2/description.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library2/description.md b/library2/description.md index 9e733f0..449651a 100644 --- a/library2/description.md +++ b/library2/description.md @@ -28,3 +28,7 @@ Output: ``` 1 ``` + +Explanation: + +If you understand the word 'ok', you can understand the word 'blah'. If you understand 'ok' and 'blah', you can understand 'iz'. 'iz', and 'ok' lets you understand 'yiq'. 'yiq', 'iz', and 'blah' let you understand 'arggiq'.