藍橋杯 省賽 試題 D: REPEAT 程式 多種解法(替換/正則)

2020-10-16 14:00:32

試題 D: REPEAT 程式

  大家好,我叫亓官劼(qí guān jié ),在CSDN中記錄學習的點滴歷程,時光荏苒,未來可期,加油~博主目前僅在CSDN中寫部落格,唯一部落格更新的地址為:亓官劼的部落格

本文原創為亓官劼,請大家支援原創,部分平臺一直在惡意盜取博主的文章!!!


本題總分:10 分

【問題描述】

附件 prog.txt 中是一個用某種語言寫的程式。

其中 REPEAT k 表示一個次數為 k 的迴圈。迴圈控制的範圍由縮排表達,

從次行開始連續的縮排比該行多的(前面的空白更長的)為迴圈包含的內容。

例如如下片段:

REPEAT 2:

 A = A + 4

 REPEAT 5:

  REPEAT 6:

   A = A + 5

  A = A + 7

 A = A + 8

A = A + 9

該片段中從 A = A + 4 所在的行到 A = A + 8 所在的行都在第一行的

迴圈兩次中。

REPEAT 6: 所在的行到 A = A + 7 所在的行都在 REPEAT 5: 迴圈中。

A = A + 5 實際總共的迴圈次數是 2 × 5 × 6 = 60 次。

請問該程式執行完畢之後,A 的值是多少?

【答案提交】

這是一道結果填空題,你只需要算出結果後提交即可。本題的結果為一個

整數,在提交答案時只填寫這個整數,填寫多餘的內容將無法得分。

試題D 題解一:轉換

這題附件中的完整程式在:試題D附件程式

這題是填空題,所以我們還是可以使用Python來進行處理,可以方便點,當前,C/C++也是可以的,這裡提供一個Python版本的處理方法

dir = '/Users/qiguan/Downloads/C++大學B組/REPEAT程式.txt'
file = open(dir)
data = file.read()
len = data.__len__()


def get_indent(i):
    now_indent = 0
    while data[i] == ' ':
        now_indent = now_indent + 1
        i = i + 1
    return now_indent, i


def get_flag(i):
    if data[i] == 'R':
        i = i + 7
        return 1, i
    if data[i] == 'A':
        i = i + 8
        return 2, i


# 當前處理中的行前縮排空格數
indent = 0
# 控制下標
i = 5
# A的值
A = 0
# 乘數
multiplier =  1
# 乘數 集合
multiplier_list = []
flag = 0
while i != len:
    if data[i] == '\n':
        i = i + 1
        if i >= len -1:
            break
        now_indent, i = get_indent(i)
        flag, i = get_flag(i)
        if now_indent < indent:
            multiplier /= multiplier_list[-1]
            multiplier_list.pop()
        if flag == 1:
            multiplier *= int(data[i])
            multiplier_list.append(int(data[i]))
            i += 2
        # A = A +
        if flag == 2:
            A += int(data[i])*multiplier
            i += 1
        indent = now_indent
print(A)

答案:241830

解法二:正則替換

這裡面縮排正好也是Python的控制方法,我們可以使用正則將它替換為Python語句,然後執行即可。關鍵替換程式碼為:a為附件中的程式,下面有完整程式碼

a = re.sub("        REPEAT ","        for k in range(",a)
a = re.sub(":","):",a)
a = re.sub("    REPEAT ","    for j in range(",a)
a = re.sub("REPEAT ","for i in range(",a)

print(a)

包含a的完整程式為:

import re
a = """
A = 0
REPEAT 2:
    A = A + 4
    REPEAT 5:
        REPEAT 6:
            A = A + 5
        A = A + 7
    REPEAT 6:
        A = A + 7
        REPEAT 4:
            A = A + 2
            A = A + 7
        A = A + 2
    REPEAT 7:
        REPEAT 4:
            A = A + 8
            A = A + 7
            A = A + 4
            A = A + 5
        A = A + 8
    REPEAT 8:
        A = A + 5
        REPEAT 1:
            A = A + 2
        REPEAT 7:
            A = A + 5
        A = A + 5
    REPEAT 2:
        REPEAT 3:
            A = A + 1
        A = A + 1
    REPEAT 5:
        A = A + 1
    REPEAT 9:
        REPEAT 6:
            A = A + 5
            A = A + 1
        REPEAT 6:
            A = A + 2
            A = A + 8
            A = A + 3
        REPEAT 2:
            A = A + 5
        REPEAT 3:
            A = A + 9
        REPEAT 1:
            A = A + 4
        REPEAT 2:
            A = A + 9
        REPEAT 1:
            A = A + 6
            A = A + 6
            A = A + 4
        REPEAT 3:
            A = A + 7
        A = A + 1
        REPEAT 2:
            A = A + 3
        REPEAT 5:
            A = A + 2
            A = A + 5
            A = A + 2
        A = A + 4
    A = A + 3
REPEAT 4:
    A = A + 4
    A = A + 3
    A = A + 7
    REPEAT 5:
        REPEAT 4:
            A = A + 5
            A = A + 7
        REPEAT 5:
            A = A + 3
        REPEAT 3:
            A = A + 3
            A = A + 1
        A = A + 8
        A = A + 2
        REPEAT 9:
            A = A + 5
        REPEAT 1:
            A = A + 5
        A = A + 2
    A = A + 8
A = A + 6
REPEAT 3:
    REPEAT 4:
        A = A + 9
        REPEAT 5:
            A = A + 2
        A = A + 1
    REPEAT 9:
        A = A + 9
        A = A + 2
        REPEAT 1:
            A = A + 6
            A = A + 8
        REPEAT 2:
            A = A + 9
            A = A + 4
        A = A + 7
    REPEAT 2:
        REPEAT 7:
            A = A + 3
            A = A + 5
        REPEAT 3:
            A = A + 5
            A = A + 3
            A = A + 6
            A = A + 4
        REPEAT 9:
            A = A + 2
            A = A + 8
            A = A + 2
        A = A + 3
    REPEAT 2:
        REPEAT 8:
            A = A + 5
            A = A + 1
        A = A + 6
        A = A + 1
    A = A + 2
    REPEAT 6:
        REPEAT 1:
            A = A + 3
        REPEAT 1:
            A = A + 2
        REPEAT 4:
            A = A + 7
            A = A + 1
        A = A + 8
        REPEAT 6:
            A = A + 5
        REPEAT 6:
            A = A + 3
        REPEAT 2:
            A = A + 2
            A = A + 9
        A = A + 7
    REPEAT 9:
        A = A + 8
        REPEAT 9:
            A = A + 8
            A = A + 9
            A = A + 3
        A = A + 2
        REPEAT 6:
            A = A + 3
        REPEAT 9:
            A = A + 1
        A = A + 9
        A = A + 5
        REPEAT 2:
            A = A + 4
            A = A + 9
        A = A + 8
        REPEAT 5:
            A = A + 6
            A = A + 9
        A = A + 1
    REPEAT 1:
        A = A + 4
    A = A + 2
    REPEAT 9:
        REPEAT 3:
            A = A + 4
        REPEAT 7:
            A = A + 8
            A = A + 3
        REPEAT 5:
            A = A + 9
        REPEAT 8:
            A = A + 9
            A = A + 8
        REPEAT 4:
            A = A + 7
        A = A + 7
    A = A + 3
A = A + 5
REPEAT 6:
    A = A + 7
REPEAT 7:
    A = A + 2
    A = A + 2
A = A + 1
REPEAT 8:
    REPEAT 1:
        REPEAT 4:
            A = A + 6
            A = A + 6
            A = A + 2
        REPEAT 5:
            A = A + 4
            A = A + 8
            A = A + 4
        REPEAT 1:
            A = A + 5
        REPEAT 7:
            A = A + 8
        REPEAT 6:
            A = A + 4
        A = A + 4
        A = A + 8
        REPEAT 4:
            A = A + 2
        REPEAT 2:
            A = A + 4
        REPEAT 2:
            A = A + 3
        REPEAT 1:
            A = A + 2
        A = A + 8
        REPEAT 2:
            A = A + 7
        REPEAT 8:
            A = A + 6
            A = A + 1
        A = A + 7
    REPEAT 8:
        A = A + 2
    REPEAT 8:
        REPEAT 6:
            A = A + 1
            A = A + 6
        REPEAT 2:
            A = A + 4
            A = A + 1
        A = A + 7
    A = A + 4
REPEAT 4:
    REPEAT 9:
        A = A + 2
    REPEAT 1:
        A = A + 2
    A = A + 5
REPEAT 8:
    REPEAT 6:
        A = A + 3
    REPEAT 4:
        A = A + 1
        A = A + 6
        A = A + 1
    REPEAT 7:
        A = A + 7
        REPEAT 7:
            A = A + 3
            A = A + 9
            A = A + 1
            A = A + 9
        REPEAT 3:
            A = A + 5
        A = A + 5
        A = A + 6
        A = A + 2
    REPEAT 1:
        A = A + 4
    REPEAT 2:
        A = A + 7
    REPEAT 1:
        A = A + 7
        REPEAT 4:
            A = A + 7
        A = A + 2
        REPEAT 5:
            A = A + 9
            A = A + 1
            A = A + 9
            A = A + 5
            A = A + 9
        REPEAT 5:
            A = A + 5
        REPEAT 1:
            A = A + 6
        REPEAT 2:
            A = A + 3
            A = A + 2
            A = A + 6
            A = A + 8
            A = A + 8
            A = A + 7
        A = A + 5
    A = A + 5
REPEAT 2:
    A = A + 1
    A = A + 7
A = A + 3
REPEAT 2:
    A = A + 7
A = A + 1
A = A + 4
REPEAT 1:
    REPEAT 7:
        REPEAT 2:
            A = A + 3
            A = A + 5
            A = A + 2
        A = A + 6
    A = A + 1
A = A + 2
A = A + 4
A = A + 9
REPEAT 1:
    A = A + 8
REPEAT 8:
    REPEAT 4:
        REPEAT 8:
            A = A + 4
        REPEAT 3:
            A = A + 1
            A = A + 8
        REPEAT 7:
            A = A + 8
        REPEAT 7:
            A = A + 7
        A = A + 7
        REPEAT 7:
            A = A + 6
        REPEAT 5:
            A = A + 9
        A = A + 3
        REPEAT 4:
            A = A + 5
        A = A + 5
    A = A + 4
    REPEAT 9:
        REPEAT 3:
            A = A + 4
            A = A + 3
            A = A + 6
        REPEAT 1:
            A = A + 3
            A = A + 3
            A = A + 6
        REPEAT 6:
            A = A + 7
            A = A + 7
            A = A + 5
            A = A + 5
            A = A + 1
            A = A + 2
        A = A + 6
        A = A + 6
    REPEAT 9:
        A = A + 6
    REPEAT 1:
        REPEAT 2:
            A = A + 4
            A = A + 7
        REPEAT 3:
            A = A + 6
        REPEAT 5:
            A = A + 3
        A = A + 6
        REPEAT 9:
            A = A + 3
        A = A + 6
    REPEAT 5:
        A = A + 8
        A = A + 8
        REPEAT 3:
            A = A + 7
            A = A + 9
            A = A + 8
            A = A + 3
        A = A + 3
    A = A + 9
REPEAT 6:
    A = A + 9
A = A + 1
REPEAT 4:
    REPEAT 1:
        A = A + 7
    REPEAT 9:
        A = A + 2
        A = A + 9
    A = A + 1
A = A + 2
A = A + 8
A = A + 7
A = A + 9
A = A + 6
REPEAT 4:
    REPEAT 2:
        A = A + 3
    REPEAT 3:
        A = A + 4
    A = A + 4
REPEAT 6:
    A = A + 6
A = A + 1
A = A + 5
A = A + 8
REPEAT 2:
    A = A + 6
    REPEAT 1:
        REPEAT 2:
            A = A + 2
        REPEAT 3:
            A = A + 1
        REPEAT 1:
            A = A + 8
            A = A + 7
            A = A + 4
            A = A + 2
            A = A + 8
        A = A + 4
    REPEAT 5:
        REPEAT 6:
            A = A + 8
        REPEAT 9:
            A = A + 5
        A = A + 5
    REPEAT 5:
        A = A + 5
    REPEAT 3:
        REPEAT 5:
            A = A + 4
        REPEAT 4:
            A = A + 6
            A = A + 3
        REPEAT 7:
            A = A + 3
            A = A + 3
            A = A + 1
            A = A + 7
            A = A + 7
            A = A + 6
            A = A + 5
            A = A + 5
        A = A + 6
    REPEAT 1:
        A = A + 9
    A = A + 3
    REPEAT 1:
        REPEAT 1:
            A = A + 1
        REPEAT 8:
            A = A + 5
        REPEAT 8:
            A = A + 6
        REPEAT 4:
            A = A + 9
        A = A + 4
    REPEAT 2:
        A = A + 3
        A = A + 7
        REPEAT 5:
            A = A + 7
            A = A + 5
            A = A + 8
        A = A + 7
        A = A + 8
    A = A + 5
    REPEAT 2:
        A = A + 5
    A = A + 7
    A = A + 8
A = A + 5
A = A + 9
REPEAT 2:
    REPEAT 6:
        A = A + 9
        A = A + 1
        A = A + 8
        A = A + 7
        A = A + 1
        A = A + 5
    REPEAT 3:
        A = A + 3
        A = A + 9
        A = A + 7
    REPEAT 3:
        A = A + 9
    A = A + 1
    REPEAT 6:
        A = A + 1
    REPEAT 9:
        REPEAT 7:
            A = A + 3
        REPEAT 5:
            A = A + 5
            A = A + 8
            A = A + 8
            A = A + 1
            A = A + 2
        REPEAT 4:
            A = A + 6
        REPEAT 3:
            A = A + 3
        A = A + 7
    REPEAT 8:
        REPEAT 1:
            A = A + 7
        A = A + 8
        A = A + 3
    A = A + 1
A = A + 2
A = A + 4
A = A + 7
REPEAT 1:
    REPEAT 1:
        REPEAT 1:
            A = A + 4
            A = A + 6
        REPEAT 1:
            A = A + 3
            A = A + 9
            A = A + 6
        REPEAT 9:
            A = A + 1
            A = A + 6
        REPEAT 5:
            A = A + 3
            A = A + 9
        A = A + 5
        A = A + 5
    A = A + 7
    A = A + 2
    REPEAT 2:
        A = A + 7
    A = A + 7
    REPEAT 7:
        REPEAT 4:
            A = A + 6
        A = A + 8
        REPEAT 6:
            A = A + 6
        REPEAT 2:
            A = A + 1
        A = A + 7
        A = A + 6
    A = A + 7
    REPEAT 4:
        REPEAT 7:
            A = A + 1
        REPEAT 2:
            A = A + 2
            A = A + 5
        A = A + 8
    A = A + 2
A = A + 1
A = A + 4
REPEAT 8:
    A = A + 5
A = A + 6
REPEAT 7:
    REPEAT 6:
        REPEAT 9:
            A = A + 7
            A = A + 8
        REPEAT 4:
            A = A + 6
            A = A + 4
            A = A + 3
            A = A + 6
        REPEAT 9:
            A = A + 3
        REPEAT 9:
            A = A + 2
        A = A + 7
    A = A + 5
    A = A + 2
REPEAT 7:
    REPEAT 8:
        REPEAT 6:
            A = A + 4
            A = A + 9
            A = A + 5
            A = A + 3
        A = A + 9
    REPEAT 4:
        REPEAT 1:
            A = A + 6
            A = A + 8
        REPEAT 1:
            A = A + 6
        A = A + 4
        A = A + 6
    REPEAT 3:
        A = A + 7
        REPEAT 3:
            A = A + 4
            A = A + 4
            A = A + 2
        A = A + 3
        A = A + 7
    REPEAT 5:
        A = A + 6
        A = A + 5
    REPEAT 1:
        REPEAT 8:
            A = A + 5
        REPEAT 3:
            A = A + 6
        REPEAT 9:
            A = A + 4
        A = A + 3
    REPEAT 6:
        REPEAT 2:
            A = A + 1
        A = A + 5
    A = A + 2
A = A + 2
A = A + 7
REPEAT 4:
    A = A + 7
A = A + 9
A = A + 2
REPEAT 8:
    A = A + 9
    REPEAT 9:
        REPEAT 2:
            A = A + 3
            A = A + 2
            A = A + 1
            A = A + 5
        REPEAT 9:
            A = A + 1
            A = A + 3
        A = A + 9
        REPEAT 7:
            A = A + 2
        REPEAT 5:
            A = A + 9
            A = A + 3
        REPEAT 2:
            A = A + 4
        REPEAT 8:
            A = A + 9
        REPEAT 5:
            A = A + 5
            A = A + 4
        A = A + 2
    A = A + 4
    REPEAT 6:
        A = A + 2
        REPEAT 5:
            A = A + 7
            A = A + 7
            A = A + 8
            A = A + 3
        REPEAT 8:
            A = A + 2
            A = A + 5
        REPEAT 1:
            A = A + 8
            A = A + 5
            A = A + 1
            A = A + 1
        A = A + 5
        REPEAT 2:
            A = A + 6
        REPEAT 6:
            A = A + 9
            A = A + 2
        A = A + 5
        REPEAT 4:
            A = A + 7
        A = A + 1
        REPEAT 6:
            A = A + 8
        A = A + 4
    REPEAT 3:
        REPEAT 2:
            A = A + 1
            A = A + 5
        REPEAT 2:
            A = A + 7
        REPEAT 9:
            A = A + 6
            A = A + 8
            A = A + 9
        A = A + 5
    REPEAT 9:
        REPEAT 3:
            A = A + 7
            A = A + 7
        A = A + 9
        A = A + 7
        REPEAT 5:
            A = A + 7
            A = A + 2
        A = A + 1
    A = A + 8
    A = A + 3
    A = A + 5
A = A + 1
REPEAT 8:
    A = A + 4
A = A + 2
A = A + 2
A = A + 8
REPEAT 4:
    REPEAT 4:
        A = A + 8
        REPEAT 7:
            A = A + 5
            A = A + 2
        REPEAT 2:
            A = A + 6
        REPEAT 4:
            A = A + 8
            A = A + 6
        A = A + 1
    A = A + 3
A = A + 2
A = A + 7
A = A + 4
REPEAT 8:
    A = A + 2
    A = A + 4
REPEAT 5:
    REPEAT 3:
        REPEAT 6:
            A = A + 8
            A = A + 1
        A = A + 6
    A = A + 5
    A = A + 9
REPEAT 8:
    A = A + 7
REPEAT 6:
    A = A + 4
A = A + 5
REPEAT 3:
    A = A + 1
    REPEAT 1:
        REPEAT 5:
            A = A + 6
        A = A + 2
    REPEAT 9:
        REPEAT 5:
            A = A + 9
            A = A + 3
        REPEAT 9:
            A = A + 9
        A = A + 8
    REPEAT 8:
        REPEAT 5:
            A = A + 9
            A = A + 4
        REPEAT 9:
            A = A + 3
        A = A + 4
    A = A + 5
REPEAT 9:
    REPEAT 7:
        A = A + 5
    REPEAT 3:
        A = A + 7
    REPEAT 9:
        REPEAT 6:
            A = A + 4
        A = A + 6
    REPEAT 5:
        REPEAT 6:
            A = A + 5
            A = A + 3
        A = A + 3
    A = A + 3
    A = A + 5
    REPEAT 7:
        A = A + 5
        REPEAT 2:
            A = A + 5
            A = A + 6
        REPEAT 2:
            A = A + 2
        A = A + 5
    A = A + 3
A = A + 5
A = A + 5
REPEAT 4:
    A = A + 2
    A = A + 1
    REPEAT 9:
        A = A + 9
        A = A + 5
        A = A + 6
        A = A + 2
        A = A + 2
        A = A + 5
    REPEAT 9:
        A = A + 5
    A = A + 4
    REPEAT 4:
        REPEAT 4:
            A = A + 1
            A = A + 2
        REPEAT 6:
            A = A + 9
            A = A + 3
        REPEAT 2:
            A = A + 5
            A = A + 1
            A = A + 1
            A = A + 3
        A = A + 8
        REPEAT 7:
            A = A + 4
        REPEAT 6:
            A = A + 9
        REPEAT 5:
            A = A + 9
            A = A + 8
            A = A + 3
        A = A + 9
        A = A + 4
    A = A + 6
REPEAT 7:
    A = A + 9
REPEAT 9:
    A = A + 4
    A = A + 9
    A = A + 1
    A = A + 3
    REPEAT 5:
        REPEAT 1:
            A = A + 4
            A = A + 4
        REPEAT 8:
            A = A + 9
            A = A + 6
            A = A + 2
        REPEAT 3:
            A = A + 4
            A = A + 4
        REPEAT 3:
            A = A + 5
            A = A + 2
            A = A + 8
            A = A + 3
            A = A + 6
            A = A + 4
            A = A + 9
            A = A + 1
        A = A + 9
        A = A + 5
        A = A + 3
        REPEAT 3:
            A = A + 2
            A = A + 5
            A = A + 8
            A = A + 2
        A = A + 5
    REPEAT 8:
        REPEAT 2:
            A = A + 6
        A = A + 7
    A = A + 6
    A = A + 9
    A = A + 2
REPEAT 2:
    A = A + 3
    REPEAT 8:
        A = A + 7
        A = A + 2
        A = A + 1
        A = A + 4
        A = A + 1
        A = A + 5
    A = A + 2
    A = A + 1
    REPEAT 1:
        A = A + 1
    REPEAT 6:
        A = A + 4
        A = A + 3
    A = A + 3
    REPEAT 5:
        A = A + 3
    REPEAT 6:
        REPEAT 1:
            A = A + 5
            A = A + 7
            A = A + 7
            A = A + 7
        REPEAT 5:
            A = A + 9
        A = A + 7
        REPEAT 5:
            A = A + 9
            A = A + 1
            A = A + 9
        A = A + 8
        REPEAT 1:
            A = A + 2
        REPEAT 5:
            A = A + 8
        REPEAT 3:
            A = A + 2
            A = A + 9
        A = A + 6
        A = A + 3
    REPEAT 5:
        REPEAT 6:
            A = A + 5
            A = A + 5
        REPEAT 4:
            A = A + 5
        A = A + 4
        REPEAT 8:
            A = A + 9
            A = A + 1
        REPEAT 8:
            A = A + 8
            A = A + 1
        A = A + 4
        REPEAT 6:
            A = A + 6
        REPEAT 2:
            A = A + 3
            A = A + 9
            A = A + 6
            A = A + 9
        REPEAT 1:
            A = A + 4
        REPEAT 3:
            A = A + 3
            A = A + 4
            A = A + 2
            A = A + 8
        REPEAT 2:
            A = A + 4
        A = A + 1
        REPEAT 9:
            A = A + 2
        A = A + 9
    A = A + 7
REPEAT 7:
    REPEAT 7:
        REPEAT 5:
            A = A + 7
        REPEAT 5:
            A = A + 1
        A = A + 1
    REPEAT 5:
        A = A + 6
        REPEAT 1:
            A = A + 4
        REPEAT 9:
            A = A + 4
        A = A + 1
    REPEAT 6:
        A = A + 8
        A = A + 5
        REPEAT 1:
            A = A + 4
        REPEAT 5:
            A = A + 8
            A = A + 7
        A = A + 2
    REPEAT 3:
        A = A + 3
    REPEAT 8:
        REPEAT 8:
            A = A + 4
        A = A + 7
        REPEAT 5:
            A = A + 1
        REPEAT 8:
            A = A + 7
            A = A + 8
            A = A + 4
        A = A + 7
        A = A + 6
    A = A + 9
    A = A + 5
REPEAT 3:
    A = A + 5
    REPEAT 9:
        A = A + 1
    A = A + 7
REPEAT 1:
    A = A + 8
A = A + 4
REPEAT 8:
    REPEAT 7:
        A = A + 2
        REPEAT 4:
            A = A + 6
        A = A + 6
    REPEAT 1:
        A = A + 7
    A = A + 1
REPEAT 9:
    REPEAT 5:
        A = A + 6
        A = A + 5
        REPEAT 7:
            A = A + 3
            A = A + 6
        A = A + 8
    REPEAT 2:
        A = A + 7
    A = A + 1
    A = A + 9
    REPEAT 3:
        REPEAT 3:
            A = A + 5
"""
a = re.sub("        REPEAT ","        for k in range(",a)
a = re.sub(":","):",a)
a = re.sub("    REPEAT ","    for j in range(",a)
a = re.sub("REPEAT ","for i in range(",a)

print(a)

轉換後的Python程式為:

A = 0
for i in range(2):
    A = A + 4
    for j in range(5):
        for k in range(6):
            A = A + 5
        A = A + 7
    for j in range(6):
        A = A + 7
        for k in range(4):
            A = A + 2
            A = A + 7
        A = A + 2
    for j in range(7):
        for k in range(4):
            A = A + 8
            A = A + 7
            A = A + 4
            A = A + 5
        A = A + 8
    for j in range(8):
        A = A + 5
        for k in range(1):
            A = A + 2
        for k in range(7):
            A = A + 5
        A = A + 5
    for j in range(2):
        for k in range(3):
            A = A + 1
        A = A + 1
    for j in range(5):
        A = A + 1
    for j in range(9):
        for k in range(6):
            A = A + 5
            A = A + 1
        for k in range(6):
            A = A + 2
            A = A + 8
            A = A + 3
        for k in range(2):
            A = A + 5
        for k in range(3):
            A = A + 9
        for k in range(1):
            A = A + 4
        for k in range(2):
            A = A + 9
        for k in range(1):
            A = A + 6
            A = A + 6
            A = A + 4
        for k in range(3):
            A = A + 7
        A = A + 1
        for k in range(2):
            A = A + 3
        for k in range(5):
            A = A + 2
            A = A + 5
            A = A + 2
        A = A + 4
    A = A + 3
for i in range(4):
    A = A + 4
    A = A + 3
    A = A + 7
    for j in range(5):
        for k in range(4):
            A = A + 5
            A = A + 7
        for k in range(5):
            A = A + 3
        for k in range(3):
            A = A + 3
            A = A + 1
        A = A + 8
        A = A + 2
        for k in range(9):
            A = A + 5
        for k in range(1):
            A = A + 5
        A = A + 2
    A = A + 8
A = A + 6
for i in range(3):
    for j in range(4):
        A = A + 9
        for k in range(5):
            A = A + 2
        A = A + 1
    for j in range(9):
        A = A + 9
        A = A + 2
        for k in range(1):
            A = A + 6
            A = A + 8
        for k in range(2):
            A = A + 9
            A = A + 4
        A = A + 7
    for j in range(2):
        for k in range(7):
            A = A + 3
            A = A + 5
        for k in range(3):
            A = A + 5
            A = A + 3
            A = A + 6
            A = A + 4
        for k in range(9):
            A = A + 2
            A = A + 8
            A = A + 2
        A = A + 3
    for j in range(2):
        for k in range(8):
            A = A + 5
            A = A + 1
        A = A + 6
        A = A + 1
    A = A + 2
    for j in range(6):
        for k in range(1):
            A = A + 3
        for k in range(1):
            A = A + 2
        for k in range(4):
            A = A + 7
            A = A + 1
        A = A + 8
        for k in range(6):
            A = A + 5
        for k in range(6):
            A = A + 3
        for k in range(2):
            A = A + 2
            A = A + 9
        A = A + 7
    for j in range(9):
        A = A + 8
        for k in range(9):
            A = A + 8
            A = A + 9
            A = A + 3
        A = A + 2
        for k in range(6):
            A = A + 3
        for k in range(9):
            A = A + 1
        A = A + 9
        A = A + 5
        for k in range(2):
            A = A + 4
            A = A + 9
        A = A + 8
        for k in range(5):
            A = A + 6
            A = A + 9
        A = A + 1
    for j in range(1):
        A = A + 4
    A = A + 2
    for j in range(9):
        for k in range(3):
            A = A + 4
        for k in range(7):
            A = A + 8
            A = A + 3
        for k in range(5):
            A = A + 9
        for k in range(8):
            A = A + 9
            A = A + 8
        for k in range(4):
            A = A + 7
        A = A + 7
    A = A + 3
A = A + 5
for i in range(6):
    A = A + 7
for i in range(7):
    A = A + 2
    A = A + 2
A = A + 1
for i in range(8):
    for j in range(1):
        for k in range(4):
            A = A + 6
            A = A + 6
            A = A + 2
        for k in range(5):
            A = A + 4
            A = A + 8
            A = A + 4
        for k in range(1):
            A = A + 5
        for k in range(7):
            A = A + 8
        for k in range(6):
            A = A + 4
        A = A + 4
        A = A + 8
        for k in range(4):
            A = A + 2
        for k in range(2):
            A = A + 4
        for k in range(2):
            A = A + 3
        for k in range(1):
            A = A + 2
        A = A + 8
        for k in range(2):
            A = A + 7
        for k in range(8):
            A = A + 6
            A = A + 1
        A = A + 7
    for j in range(8):
        A = A + 2
    for j in range(8):
        for k in range(6):
            A = A + 1
            A = A + 6
        for k in range(2):
            A = A + 4
            A = A + 1
        A = A + 7
    A = A + 4
for i in range(4):
    for j in range(9):
        A = A + 2
    for j in range(1):
        A = A + 2
    A = A + 5
for i in range(8):
    for j in range(6):
        A = A + 3
    for j in range(4):
        A = A + 1
        A = A + 6
        A = A + 1
    for j in range(7):
        A = A + 7
        for k in range(7):
            A = A + 3
            A = A + 9
            A = A + 1
            A = A + 9
        for k in range(3):
            A = A + 5
        A = A + 5
        A = A + 6
        A = A + 2
    for j in range(1):
        A = A + 4
    for j in range(2):
        A = A + 7
    for j in range(1):
        A = A + 7
        for k in range(4):
            A = A + 7
        A = A + 2
        for k in range(5):
            A = A + 9
            A = A + 1
            A = A + 9
            A = A + 5
            A = A + 9
        for k in range(5):
            A = A + 5
        for k in range(1):
            A = A + 6
        for k in range(2):
            A = A + 3
            A = A + 2
            A = A + 6
            A = A + 8
            A = A + 8
            A = A + 7
        A = A + 5
    A = A + 5
for i in range(2):
    A = A + 1
    A = A + 7
A = A + 3
for i in range(2):
    A = A + 7
A = A + 1
A = A + 4
for i in range(1):
    for j in range(7):
        for k in range(2):
            A = A + 3
            A = A + 5
            A = A + 2
        A = A + 6
    A = A + 1
A = A + 2
A = A + 4
A = A + 9
for i in range(1):
    A = A + 8
for i in range(8):
    for j in range(4):
        for k in range(8):
            A = A + 4
        for k in range(3):
            A = A + 1
            A = A + 8
        for k in range(7):
            A = A + 8
        for k in range(7):
            A = A + 7
        A = A + 7
        for k in range(7):
            A = A + 6
        for k in range(5):
            A = A + 9
        A = A + 3
        for k in range(4):
            A = A + 5
        A = A + 5
    A = A + 4
    for j in range(9):
        for k in range(3):
            A = A + 4
            A = A + 3
            A = A + 6
        for k in range(1):
            A = A + 3
            A = A + 3
            A = A + 6
        for k in range(6):
            A = A + 7
            A = A + 7
            A = A + 5
            A = A + 5
            A = A + 1
            A = A + 2
        A = A + 6
        A = A + 6
    for j in range(9):
        A = A + 6
    for j in range(1):
        for k in range(2):
            A = A + 4
            A = A + 7
        for k in range(3):
            A = A + 6
        for k in range(5):
            A = A + 3
        A = A + 6
        for k in range(9):
            A = A + 3
        A = A + 6
    for j in range(5):
        A = A + 8
        A = A + 8
        for k in range(3):
            A = A + 7
            A = A + 9
            A = A + 8
            A = A + 3
        A = A + 3
    A = A + 9
for i in range(6):
    A = A + 9
A = A + 1
for i in range(4):
    for j in range(1):
        A = A + 7
    for j in range(9):
        A = A + 2
        A = A + 9
    A = A + 1
A = A + 2
A = A + 8
A = A + 7
A = A + 9
A = A + 6
for i in range(4):
    for j in range(2):
        A = A + 3
    for j in range(3):
        A = A + 4
    A = A + 4
for i in range(6):
    A = A + 6
A = A + 1
A = A + 5
A = A + 8
for i in range(2):
    A = A + 6
    for j in range(1):
        for k in range(2):
            A = A + 2
        for k in range(3):
            A = A + 1
        for k in range(1):
            A = A + 8
            A = A + 7
            A = A + 4
            A = A + 2
            A = A + 8
        A = A + 4
    for j in range(5):
        for k in range(6):
            A = A + 8
        for k in range(9):
            A = A + 5
        A = A + 5
    for j in range(5):
        A = A + 5
    for j in range(3):
        for k in range(5):
            A = A + 4
        for k in range(4):
            A = A + 6
            A = A + 3
        for k in range(7):
            A = A + 3
            A = A + 3
            A = A + 1
            A = A + 7
            A = A + 7
            A = A + 6
            A = A + 5
            A = A + 5
        A = A + 6
    for j in range(1):
        A = A + 9
    A = A + 3
    for j in range(1):
        for k in range(1):
            A = A + 1
        for k in range(8):
            A = A + 5
        for k in range(8):
            A = A + 6
        for k in range(4):
            A = A + 9
        A = A + 4
    for j in range(2):
        A = A + 3
        A = A + 7
        for k in range(5):
            A = A + 7
            A = A + 5
            A = A + 8
        A = A + 7
        A = A + 8
    A = A + 5
    for j in range(2):
        A = A + 5
    A = A + 7
    A = A + 8
A = A + 5
A = A + 9
for i in range(2):
    for j in range(6):
        A = A + 9
        A = A + 1
        A = A + 8
        A = A + 7
        A = A + 1
        A = A + 5
    for j in range(3):
        A = A + 3
        A = A + 9
        A = A + 7
    for j in range(3):
        A = A + 9
    A = A + 1
    for j in range(6):
        A = A + 1
    for j in range(9):
        for k in range(7):
            A = A + 3
        for k in range(5):
            A = A + 5
            A = A + 8
            A = A + 8
            A = A + 1
            A = A + 2
        for k in range(4):
            A = A + 6
        for k in range(3):
            A = A + 3
        A = A + 7
    for j in range(8):
        for k in range(1):
            A = A + 7
        A = A + 8
        A = A + 3
    A = A + 1
A = A + 2
A = A + 4
A = A + 7
for i in range(1):
    for j in range(1):
        for k in range(1):
            A = A + 4
            A = A + 6
        for k in range(1):
            A = A + 3
            A = A + 9
            A = A + 6
        for k in range(9):
            A = A + 1
            A = A + 6
        for k in range(5):
            A = A + 3
            A = A + 9
        A = A + 5
        A = A + 5
    A = A + 7
    A = A + 2
    for j in range(2):
        A = A + 7
    A = A + 7
    for j in range(7):
        for k in range(4):
            A = A + 6
        A = A + 8
        for k in range(6):
            A = A + 6
        for k in range(2):
            A = A + 1
        A = A + 7
        A = A + 6
    A = A + 7
    for j in range(4):
        for k in range(7):
            A = A + 1
        for k in range(2):
            A = A + 2
            A = A + 5
        A = A + 8
    A = A + 2
A = A + 1
A = A + 4
for i in range(8):
    A = A + 5
A = A + 6
for i in range(7):
    for j in range(6):
        for k in range(9):
            A = A + 7
            A = A + 8
        for k in range(4):
            A = A + 6
            A = A + 4
            A = A + 3
            A = A + 6
        for k in range(9):
            A = A + 3
        for k in range(9):
            A = A + 2
        A = A + 7
    A = A + 5
    A = A + 2
for i in range(7):
    for j in range(8):
        for k in range(6):
            A = A + 4
            A = A + 9
            A = A + 5
            A = A + 3
        A = A + 9
    for j in range(4):
        for k in range(1):
            A = A + 6
            A = A + 8
        for k in range(1):
            A = A + 6
        A = A + 4
        A = A + 6
    for j in range(3):
        A = A + 7
        for k in range(3):
            A = A + 4
            A = A + 4
            A = A + 2
        A = A + 3
        A = A + 7
    for j in range(5):
        A = A + 6
        A = A + 5
    for j in range(1):
        for k in range(8):
            A = A + 5
        for k in range(3):
            A = A + 6
        for k in range(9):
            A = A + 4
        A = A + 3
    for j in range(6):
        for k in range(2):
            A = A + 1
        A = A + 5
    A = A + 2
A = A + 2
A = A + 7
for i in range(4):
    A = A + 7
A = A + 9
A = A + 2
for i in range(8):
    A = A + 9
    for j in range(9):
        for k in range(2):
            A = A + 3
            A = A + 2
            A = A + 1
            A = A + 5
        for k in range(9):
            A = A + 1
            A = A + 3
        A = A + 9
        for k in range(7):
            A = A + 2
        for k in range(5):
            A = A + 9
            A = A + 3
        for k in range(2):
            A = A + 4
        for k in range(8):
            A = A + 9
        for k in range(5):
            A = A + 5
            A = A + 4
        A = A + 2
    A = A + 4
    for j in range(6):
        A = A + 2
        for k in range(5):
            A = A + 7
            A = A + 7
            A = A + 8
            A = A + 3
        for k in range(8):
            A = A + 2
            A = A + 5
        for k in range(1):
            A = A + 8
            A = A + 5
            A = A + 1
            A = A + 1
        A = A + 5
        for k in range(2):
            A = A + 6
        for k in range(6):
            A = A + 9
            A = A + 2
        A = A + 5
        for k in range(4):
            A = A + 7
        A = A + 1
        for k in range(6):
            A = A + 8
        A = A + 4
    for j in range(3):
        for k in range(2):
            A = A + 1
            A = A + 5
        for k in range(2):
            A = A + 7
        for k in range(9):
            A = A + 6
            A = A + 8
            A = A + 9
        A = A + 5
    for j in range(9):
        for k in range(3):
            A = A + 7
            A = A + 7
        A = A + 9
        A = A + 7
        for k in range(5):
            A = A + 7
            A = A + 2
        A = A + 1
    A = A + 8
    A = A + 3
    A = A + 5
A = A + 1
for i in range(8):
    A = A + 4
A = A + 2
A = A + 2
A = A + 8
for i in range(4):
    for j in range(4):
        A = A + 8
        for k in range(7):
            A = A + 5
            A = A + 2
        for k in range(2):
            A = A + 6
        for k in range(4):
            A = A + 8
            A = A + 6
        A = A + 1
    A = A + 3
A = A + 2
A = A + 7
A = A + 4
for i in range(8):
    A = A + 2
    A = A + 4
for i in range(5):
    for j in range(3):
        for k in range(6):
            A = A + 8
            A = A + 1
        A = A + 6
    A = A + 5
    A = A + 9
for i in range(8):
    A = A + 7
for i in range(6):
    A = A + 4
A = A + 5
for i in range(3):
    A = A + 1
    for j in range(1):
        for k in range(5):
            A = A + 6
        A = A + 2
    for j in range(9):
        for k in range(5):
            A = A + 9
            A = A + 3
        for k in range(9):
            A = A + 9
        A = A + 8
    for j in range(8):
        for k in range(5):
            A = A + 9
            A = A + 4
        for k in range(9):
            A = A + 3
        A = A + 4
    A = A + 5
for i in range(9):
    for j in range(7):
        A = A + 5
    for j in range(3):
        A = A + 7
    for j in range(9):
        for k in range(6):
            A = A + 4
        A = A + 6
    for j in range(5):
        for k in range(6):
            A = A + 5
            A = A + 3
        A = A + 3
    A = A + 3
    A = A + 5
    for j in range(7):
        A = A + 5
        for k in range(2):
            A = A + 5
            A = A + 6
        for k in range(2):
            A = A + 2
        A = A + 5
    A = A + 3
A = A + 5
A = A + 5
for i in range(4):
    A = A + 2
    A = A + 1
    for j in range(9):
        A = A + 9
        A = A + 5
        A = A + 6
        A = A + 2
        A = A + 2
        A = A + 5
    for j in range(9):
        A = A + 5
    A = A + 4
    for j in range(4):
        for k in range(4):
            A = A + 1
            A = A + 2
        for k in range(6):
            A = A + 9
            A = A + 3
        for k in range(2):
            A = A + 5
            A = A + 1
            A = A + 1
            A = A + 3
        A = A + 8
        for k in range(7):
            A = A + 4
        for k in range(6):
            A = A + 9
        for k in range(5):
            A = A + 9
            A = A + 8
            A = A + 3
        A = A + 9
        A = A + 4
    A = A + 6
for i in range(7):
    A = A + 9
for i in range(9):
    A = A + 4
    A = A + 9
    A = A + 1
    A = A + 3
    for j in range(5):
        for k in range(1):
            A = A + 4
            A = A + 4
        for k in range(8):
            A = A + 9
            A = A + 6
            A = A + 2
        for k in range(3):
            A = A + 4
            A = A + 4
        for k in range(3):
            A = A + 5
            A = A + 2
            A = A + 8
            A = A + 3
            A = A + 6
            A = A + 4
            A = A + 9
            A = A + 1
        A = A + 9
        A = A + 5
        A = A + 3
        for k in range(3):
            A = A + 2
            A = A + 5
            A = A + 8
            A = A + 2
        A = A + 5
    for j in range(8):
        for k in range(2):
            A = A + 6
        A = A + 7
    A = A + 6
    A = A + 9
    A = A + 2
for i in range(2):
    A = A + 3
    for j in range(8):
        A = A + 7
        A = A + 2
        A = A + 1
        A = A + 4
        A = A + 1
        A = A + 5
    A = A + 2
    A = A + 1
    for j in range(1):
        A = A + 1
    for j in range(6):
        A = A + 4
        A = A + 3
    A = A + 3
    for j in range(5):
        A = A + 3
    for j in range(6):
        for k in range(1):
            A = A + 5
            A = A + 7
            A = A + 7
            A = A + 7
        for k in range(5):
            A = A + 9
        A = A + 7
        for k in range(5):
            A = A + 9
            A = A + 1
            A = A + 9
        A = A + 8
        for k in range(1):
            A = A + 2
        for k in range(5):
            A = A + 8
        for k in range(3):
            A = A + 2
            A = A + 9
        A = A + 6
        A = A + 3
    for j in range(5):
        for k in range(6):
            A = A + 5
            A = A + 5
        for k in range(4):
            A = A + 5
        A = A + 4
        for k in range(8):
            A = A + 9
            A = A + 1
        for k in range(8):
            A = A + 8
            A = A + 1
        A = A + 4
        for k in range(6):
            A = A + 6
        for k in range(2):
            A = A + 3
            A = A + 9
            A = A + 6
            A = A + 9
        for k in range(1):
            A = A + 4
        for k in range(3):
            A = A + 3
            A = A + 4
            A = A + 2
            A = A + 8
        for k in range(2):
            A = A + 4
        A = A + 1
        for k in range(9):
            A = A + 2
        A = A + 9
    A = A + 7
for i in range(7):
    for j in range(7):
        for k in range(5):
            A = A + 7
        for k in range(5):
            A = A + 1
        A = A + 1
    for j in range(5):
        A = A + 6
        for k in range(1):
            A = A + 4
        for k in range(9):
            A = A + 4
        A = A + 1
    for j in range(6):
        A = A + 8
        A = A + 5
        for k in range(1):
            A = A + 4
        for k in range(5):
            A = A + 8
            A = A + 7
        A = A + 2
    for j in range(3):
        A = A + 3
    for j in range(8):
        for k in range(8):
            A = A + 4
        A = A + 7
        for k in range(5):
            A = A + 1
        for k in range(8):
            A = A + 7
            A = A + 8
            A = A + 4
        A = A + 7
        A = A + 6
    A = A + 9
    A = A + 5
for i in range(3):
    A = A + 5
    for j in range(9):
        A = A + 1
    A = A + 7
for i in range(1):
    A = A + 8
A = A + 4
for i in range(8):
    for j in range(7):
        A = A + 2
        for k in range(4):
            A = A + 6
        A = A + 6
    for j in range(1):
        A = A + 7
    A = A + 1
for i in range(9):
    for j in range(5):
        A = A + 6
        A = A + 5
        for k in range(7):
            A = A + 3
            A = A + 6
        A = A + 8
    for j in range(2):
        A = A + 7
    A = A + 1
    A = A + 9
    for j in range(3):
        for k in range(3):
            A = A + 5
print(A)

執行後取得結果:241830

亓官劼 CSDN認證部落格專家 Python 全棧 資料結構與演演算法
大家好,我是亓官劼(qíguānjié),在部落格中分享資料結構與演演算法、Python全棧開發、Java後端開發、前端、OJ題解及各類報錯資訊解決方案等經驗。一起加油,用知識改變命運,未來可期。