---
# System prepended metadata

title: Lời giải đề thi cấp trường THPT Quốc Oai

---

# Lời giải đề thi cấp trường THPT Quốc Oai
## Câu 1:
```
import sys

sys.stdin = open('Cau1.inp', 'r')
sys.stdout = open('Cau1.out', 'w')

a = int(input())
b = int(input())
c = int(input())
k = int(input())
m = int(input())
n = int(input())

print(a*k+(m-k)*b+(n-m)*c)
```
## Câu 2:
```
import sys
sys.stdin = open('Cau2.inp', 'r')
sys.stdout = open('Cau2.out', 'w')
a = []
cnt = 0
s = input()
j = 1
for i in range(len(s)-1):
    for j in range(i+1,len(s)+1):
        if s[i:j] not in a:
            cnt += 1
        a.append(s[i:j])
print(cnt)
```
## Câu 3:
```
import sys

sys.stdin = open('Cau3.inp', 'r')
sys.stdout = open('Cau3.out', 'w')

def solve(arr, l):
    mx = arr[1]-arr[0]
    min_ele = arr[0]
    for i in range(1,l):
        if arr[i]-min_ele > mx:
            mx = arr[i]-min_ele
        if arr[i] < min_ele:
            min_ele = arr[i]
    return mx
    
n = int(input())
A = list(map(int, input().split()))
print(solve(A, len(A)))
```
## Câu 4:
```
import sys

sys.stdin = open('Cau4.inp', 'r')
sys.stdout = open('Cau4.out', 'w')

cnt = 0
def solve(n):
    res = 1
    for j in n:
        res *= int(j)
    return res

n = int(input())
while n >= 10:
    n = solve(str(n))
    cnt += 1
print(cnt)
```
## Câu 5:
```
import sys

sys.stdin = open('Cau5.inp', 'r')
sys.stdout = open('Cau5.out', 'w')

N = int(input())
GIA = [0]
GIA += [int (i) for i in input().split()]
MAX = [0 for i in range(N+6)]
GIA += [0] * 5
MAX[N] = GIA[N]

for i in range(N-1,0,-1):
    c1 = GIA[i] + MAX[i+2]
    c2 = GIA[i] + GIA[i+1] + MAX[i+4]
    c3 = GIA[i] + GIA[i+1] + GIA[i+2] + MAX[i+6]
    MAX[i] = max(c1,c2,c3)
print(MAX[1])
```