How to write to shoot?

All along we heard a lot of talk about orz "to beat"

Today can be considered to know how to beat is one thing to share with you

 

To shoot it is when you write code 

You want to verify that it is correct

But just look at the sample or sample hand-made on the subject tend to not be able to find very tedious and error

 

So we can rely on powerful computers to help us verify the correctness of the program

The next shot is of speaking about how to achieve

Our problem, for example a + b

 

First, we write std program (may be wrong)

 

 Then we write a program bs general search violence and other violence program, but we must ensure that this program is not wrong

As shown below

 

 We write a data generator data

System using a random number to generate random data

 

 Finally, we write a program "to beat"

 

 First explain what is meant above code

Line 7 is our random number generator to import data to in.txt Spanning Tree Lane

Line 8 in.txt us to import the data in to write better we may be wrong but that std program

And the results of the program into std in out.txt

Line 9 we'll put that in the same way violence program running while storing the result to ans.txt

Line 10 is the same whether the ratio of these two data outputs and ans.txt out.txt

 

Of course, we can not just get away with a set of data validation 

Therefore, we generally preceded by a while (1)

Keep manufacturing data for verification

I know that an error is found

Will return 1 return that is abnormal to shoot the program will automatically stop telling you that an error occurred

 

FIG following specific effect

 

 

 Then we found our program a + b there is a problem

Violence program to calculate the correct answer is 39268

And we wrote a program derived answer is over 39,269 more than the correct answer 1

Then we go back to our folder that look a look

 

 

 

 

 In this case the input data is above 12280 and 26988

 

 The left is the standard answer is the right answer to our output

 

So we go back to the original program picked the wrong std

Using the intermediate output way to find the error

The results we are very surprised to find

 

 

 

Line 8 is what happened how much such a line of code. . . . (amount.

 

'So far,' We explain to shoot came to an end  

If you feel good talking about

Remember to praise or add a point to walk attention Oh ~

Guess you like

Origin www.cnblogs.com/akioi/p/12218830.html