結果

問題 No.64 XORフィボナッチ数列
ユーザー rocoderrocoder
提出日時 2017-06-18 19:35:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 783 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-09 20:07:55
合計ジャッジ時間 1,150 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#xorf
import math
def tw(n):
    tt=[]
    while n>0:
        t=1
        k=0
        while t<n:
            t*=2
            k+=1
        q=math.round(n/t)
        tt.append(q)
        q*=t
        n-=q
    while k>0:
        tt.append(0)
        k-=1
    return tt
def twe(li):
    en=0.0
    t1=1
    i=len(li)-1
    while i>=0:
        en+=t1*li[i]
        t1*=2
        i-=1
    return en
def xor(l0,l1):
    l2=[]
    for i in range(len(l1)):
        if l0[i]!=l1[i]:
            l2.append(1)
        else:
            l2.append(0)
    return l2

F0,F1,N=(folat(i) for i in input().split())
if N==0.0:
    print(F0)  
elif N==1.0:
    print(F1)
else:
    F0=tw(F0)
    F1=tw(F1)
    while N>1.0:
        F2=xor(F0,F1)
        F0=F1
        F1=F2
        N-=1
    print(twe(F1))
0