We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# Enter your code here. Read input from STDIN. Print output to STDOUTc,m,n=map(int,input().split())ifn==1:print("0")else:arr=[0foriinrange(2*n+2)]arr[0]=0arr[1]=cl=[]foriinrange(2,2*n+2):arr[i]=(arr[i-1]+arr[i-2])%mforiinrange(2,2*n-2,2):temp=(arr[i]*arr[i+2]+arr[i+1]*arr[i+3])%ml.append(temp)temp=(arr[i]*arr[i+4]+arr[i+1]*arr[i+5])%ml.append(temp)temp=(arr[2*n-2]*arr[2*n]+arr[2*n-1]*arr[2*n+1])%ml.append(temp)l=set(l)print(len(l))
no need to spam your solution twice. btw you can do shorter
deffib_gen(mod):f0,f1=0,1whileTrue:yieldf0f0,f1=f1,f0+f1%mod# if ...== main bla blac,m,n=map(int,input().split())fib_it=fib_gen(m)for_inrange(7):next(fib_it)#discardf0,f1,..f6ret=len(set(c*c*fi%mforfi,_1,_2inzip(fib_it,fib_it,range(3,2*n))))print(ret)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Join us
Create a HackerRank account
Be part of a 26 million-strong community of developers
Please signup or login in order to view this challenge
Scalar Products
You are viewing a single comment's thread. Return to all comments →
Python3 solution
no need to spam your solution twice. btw you can do shorter