"Test Instructions description"
Given such an expression: x1/x2/x3/ /XK, where Xi is a positive integer. The Division expression should be summed in order from left to right. But embedding parentheses in an expression can change the order of calculations. Enter an expression that determines whether the last value of the expression can be an integer by parentheses.
Analysis
An expression can be written as e= (x1 X3 Xk)/x2; (X1 must be in the molecular position, X2 must be in the denominator position, any other)
The question becomes whether E is an integer.
For large number multiplication, there are two ways to avoid data overflow:
1. The unique decomposition theorem of prime numbers; stores the number of possible prime numbers (how to store, with an array on the line)
2. In the form of direct numerator of the formula (with each data in the molecule and X2 numerator, if the last X2 can become 1, then the expression must be an integer, otherwise it is not an integer.
Problem Promotion:
How do you find the least common multiple for a and b? (A and B are very large)
We know this formula: A*B=GCD (A, B) *LCM (A, B)
Then we can get the LCM (A, B) =a*b/gcd (A, B). But the problem comes, a*b must overflow. We can change a form to write: LCM (A, B) =a/gcd (A, b) *b; then the data will not overflow.
"Test Instructions description"
How many point on the line ax+by+c=0 (x, y) satisfies x in the interval [x1,x2] and y within the interval [y1,y2]?
The extended Euclidean algorithm program code is:
void gcd (int A,int b,int &d,int &x,int &y) { if (!B) {d=a;x=1; y=0;} Else { gcd (b,a%b,d,y,x); Y-=x* (A/b); }}
Then we can get:
1. Set A,b,c to any integer. If the equation ax+by=c a set of integer solutions (x0,y0), then its arbitrary integer solution can be written (X0+KB ', Y0-ka '). Where a ' =a/gcd (A, A, b), B. =b/gcd (A, a). K is any integer.
2. Set A,b,c to any integer, G=GCD (A, B). A set of integer solutions to the equation Ax+by=g is (x0,y0). When C is a multiple of G, Ax+by=c has a set of integer solutions (x0c/g,y0c/g).
Special topic---the high-precision operation of the division expression, extending Euclidean algorithm