• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Nov 21st, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. Задача С
2. n=int(input())
3. a=list(map(int, input().split()))
4. b=list(map(int, input().split()))
5. c=[0 for i in range (n)]
6. c=1
7. for i in range(n-1):
8.     if(a[i]==a[i+1]):
9.         c[i+1]+=c[i]
10.     if(i<n-2):
11.         if(a[i]==a[i+2]):
12.             c[i+2]+=c[i]
13.     if((a[i]!=b[i])&(b[i]!=0)):
14.         if(b[i]==a[i+1]):
15.             c[i+1]+=c[i]
16.         if(i<n-2):
17.             if(b[i]==a[i+2]):
18.                 c[i+2]+=c[i]
19. print(c[n-1]%947)
20. Задача Е
21. n=int(input())
22. a=[0 for i in range(n)]
23. b=[0 for i in range(n)]
24. if(n==0):
25.     print(1)
26. elif(n==1):
27.     print(2)
28. elif(n==2):
29.     print(4)
30. else:
31.     a=1
32.     b=1
33.     a=2
34.     b=2
35.     for i in range(2,n):
36.         a[i]=b[i-1]+b[i-2]
37.         b[i]=a[i-1]+b[i-1]
38.     print(a[n-1]+b[n-1])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?