結果

問題 No.64 XORフィボナッチ数列
ユーザー rocoderrocoder
提出日時 2017-06-20 05:15:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,070 bytes
コンパイル時間 320 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 17,948 KB
最終ジャッジ日時 2024-04-10 06:22:37
合計ジャッジ時間 7,116 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,880 KB
testcase_01 AC 29 ms
11,008 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 28 ms
11,008 KB
testcase_04 AC 28 ms
10,880 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#xorf
import math
def tw(n):
    t=1
    k=0
    while t<n:
        t*=2
        k+=1
    #    print (k)
    t/=2
    tt=[]
    while n>0:    
        q=math.floor(n/t)
 #       print (q)
        tt.append(q)
     #   print (tt)
        q*=t
        t/=2
        n-=q
    #    print (n)
        k-=1
  #  print (k)
    while k>0:
        tt.append(0)
     #   print (tt)
        k-=1
    return tt
def twe(li):
    en=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=(int(i) for i in input().split())
if N==0:
    print (F0)
#    print(int(F0))  
elif N==1:
    print(int(F1))
else:
    F0=tw(F0)
    F1=tw(F1)
    Di=len(F0)-len(F1)
    if Di>0:
        Dk=[0]*Di
        F1=Dk+F1
    elif Di<0:
        Di*=-1
        Dk=[0]*Di
        F0=Dk+F0
    while N>1:
        F2=xor(F0,F1)
        F0=F1
        F1=F2
        N-=1
    print(int(twe(F1)))
0