結果
問題 | No.64 XORフィボナッチ数列 |
ユーザー |
|
提出日時 | 2023-01-15 08:59:46 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 36 ms / 5,000 ms |
コード長 | 1,421 bytes |
コンパイル時間 | 106 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-12-27 20:17:35 |
合計ジャッジ時間 | 1,347 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 |
ソースコード
def to2(num):bList = []if num == 0:return [0]while num > 0:bList.append(num % 2)num = num // 2return bListdef to10(numList):r = 0n = len(numList)for i in range(n):r = r + numList[i] * (2 ** i)return rdef xorList(f0List, f1List, num):len0 = len(f0List)len1 = len(f1List)length = 0if len0 > len1:length = len0for i in range(len0 - len1):f1List.append(0)elif len1 > len0:length = len1for i in range(len1 - len0):f0List.append(0)else:length = len0rList = []for i in range(length):if f0List[i] == 0 and f1List[i] == 0:rList.append(0)elif f0List[i] == 1 and f1List[i] == 0:if num % 3 == 1:rList.append(0)else:rList.append(1)elif f0List[i] == 0 and f1List[i] == 1:if num % 3 == 0:rList.append(0)else:rList.append(1)else:if num % 3 == 2:rList.append(0)else:rList.append(1)return rListf0, f1, n = map(int, input().split())rbList = []if n == 0:r = f0elif n == 1:r = f1else:f0b = to2(f0)f1b = to2(f1)rList = xorList(f0b, f1b, n)r = to10(rList)print(r)