結果
問題 | 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 // 2 return bList def to10(numList): r = 0 n = len(numList) for i in range(n): r = r + numList[i] * (2 ** i) return r def xorList(f0List, f1List, num): len0 = len(f0List) len1 = len(f1List) length = 0 if len0 > len1: length = len0 for i in range(len0 - len1): f1List.append(0) elif len1 > len0: length = len1 for i in range(len1 - len0): f0List.append(0) else: length = len0 rList = [] 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 rList f0, f1, n = map(int, input().split()) rbList = [] if n == 0: r = f0 elif n == 1: r = f1 else: f0b = to2(f0) f1b = to2(f1) rList = xorList(f0b, f1b, n) r = to10(rList) print(r)