Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mod = False
- def mult(A, B):
- Ret = []
- Ret.append(A[0] * B[0] + A[1] * B[2])
- Ret.append(A[0] * B[1] + A[1] * B[3])
- Ret.append(A[2] * B[0] + A[3] * B[2])
- Ret.append(A[2] * B[1] + A[3] * B[3])
- if mod:
- for i in range(len(Ret)):
- Ret[i] = Ret[i] % 10**100
- return Ret
- try:
- while True:
- n = int(input())
- k = 1
- pow_ = 2
- DP = []
- DP.append([1, 1, 1, 0])
- while pow_ <= n:
- DP.append(mult(DP[k - 1], DP[k - 1]))
- pow_ *= 2
- k += 1
- Out = [1, 0, 0, 1]
- while n > 0:
- if n >= pow_:
- n -= pow_
- Out = mult(DP[k], Out)
- pow_ //= 2;
- k -= 1
- print (Out[1])
- except EOFError:
- pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement