To read the following procedure, please answer the following questions:
Question 1: What are the criteria for this program?
Question 2: Does such a number exist? What is the minimum number that meets this condition?
Question 3: How long do you expect to be able to output the first result when running this program on a computer? The time is accurate to minutes (computer: Single core CPU 4.0G Hz, memory and hard disk resources are sufficient).
Question 4: How can I improve the efficiency of this program on multi-core computers?
usingSystem;usingSystem.Collections.Generic;usingSystem.Text;namespacefindthenumber{classProgram {Static voidMain (string[] args) { int[] RG = {2,3,4,5,6,7,8,9,Ten, One, A, -, -, the, -, -, -, +, -, +, A, at, -, -, -, -, -, in, -, to}; for(Int64 i =1; i < Int64.maxvalue; i++) { intHit =0; intHit1 =-1; intHit2 =-1; for(intj =0; (J < RG. Length) && (hit <=2); J + +) { if((i% rg[j])! =0) { hit++; if(hit = =1) {hit1=J; } Else if(hit = =2) {Hit2=J; } Else Break; } } if(hit = =2) && (hit1 +1==hit2)) {Console.WriteLine ("found {0}", i); } } } }}
Personal understanding: First define the shaped array RG "2~31", the target number divided by the array rg in sequential two element remainder is not equal to 0, divided by the remainder of the other elements equals 0. Such a number should exist, but very large, the query data is not the result, but can be expected to run the program directly, I am afraid even if only the first number will take a long time. Running this program on the computer, the computer CPU frequency 4.0g, Operation 4*2^30 Times per second, the first result should be (30-2) the number of least common multiple, should be very large, the calculation of the program is also very large, is expected to calculate more than 120min. Optimize the program on multicore computers and invoke multiple cores to traverse at the same time to improve operational efficiency.
Third week assignment 2