The 11th Blue Bridge Cup-REPEAT Program (Fool's Solution)

Preface

Suddenly, it seems that I haven't posted a blog for several months. I recently participated in the Blue Bridge Cup to share my speculative solution to
this problem. This solution is suitable for friends who know C/C++ and Python. If you don’t understand after reading this article, please cut me off.
One last reminder, the answer is not 403! The answer is not 403! The answer is not 403! , 403 is just the result of the code fragment, not the entire code program! ! !

Problem Description

Accessories prog.txt point I downloaded is a program written in a language used.
Among them, REPEAT k represents a cycle of number k. The range of loop control is expressed by indentation , and the content that is
continuously indented from the next line more than this line (the previous blank is longer) is the content contained in the loop.
For example, the following fragment:

REPEAT 2:
	A = A + 4
	REPEAT 5:
		REPEAT 6:
			A = A + 5
		A = A + 7
	A = A + 8
A = A + 9

In this fragment, the line from A = A + 4 to the line A = A + 8 is in the first line of the loop twice.
REPEAT 6: The line where A = A + 7 is in the REPEAT 5: loop.
A = A + 5 The actual total number of cycles is 2 × 5 × 6 = 60 times.
After the program is executed, what is the value of A?

Answer submission
This is a result fill-in-the-blank question, you only need to calculate the result and submit it.
The result of this question is an integer. Only fill in this integer when submitting the answer. If you fill in the extra content, you will not be able to score.

My special solution

When I saw this question, I was suddenly blinded. I didn't know how to do it deeply. What do I think about 1000 lines of code? Fortunately, I was witty, because this is a fill-in-the-blank question and does not require specific C/C++ code, so we can find another way.

I believe everyone has seen that I have bolded the indentation . Since the game machine has a Python environment, I immediately got the hang of it. Since it is the
indentation syntax, then you can try to modify the code of this file to Python syntax . Then add another sentence to the end of the code and print(A)
run it again with IDEL, and finally fill in the output with confidence, ok, go to the next question.
The following is the specific operation,

  1. Open prog.txt
  2. ctrl+H to open the text replacement (I believe that friends who know python at this step should suddenly realize it)
  3. The “REPEAT ”marks of all the contents enclosed replacedfor _ in range(0,
  4. Replace :all with):
  5. Add a line at the end of the codeprint(A)
  6. Run it again with IDEL
  7. come to conclusion241830

At a critical time, python gave me a hand.

the above

Guess you like

Origin blog.csdn.net/WildSky_/article/details/107548472