Блог пользователя hexor

Автор hexor, 12 лет назад, По-английски

I found a new theorem and I called it "My Remainder Theorem". My theorem finds similar thing with "Chinese Remainder Theorem". Maybe it has been founded before. If you heard this theorem before, please tell me.

Problem :

We have N equation.

x = equation_1.a ( mod equation_1.b )
x = equation_2.a ( mod equation_2.b )
.
.
.
x = equation_n.a ( mod equation_n.b )

(1<=i<=n) equation_i.b can be not a prime number. ( difference between my M.R.T. and C.R.T. )

We use a function which can do merge two equation and create a new equation. ( Let's call this function "merge" )

For example we have 3 equations. We'll solve this problem.

ans1 = merge( equation_1,equation_2 ); ans2 = merge( a,equation_3 );

Our answer is ans2.a.

Let's look at to "merge" function.

  • We assume equation_1.b > equation_2.b
  • lcm -> least common multiplier
merge( equation_1,equation_2 ){
	LCM = lcm(equation_1.b,equation_2.b)
	KKK = LCM/equation_1.b
	for i=0 to KKK-1
		if( ( i*equation_1.b + equation_1.a ) mod equation_2.b == equation_2.a )
			return answer = make_equation( LCM , i*equation_1.b+equation_1.a )	//	x = i*equation_1.b+equation_1.a(mod LCM)
	return "NO SOLUTION"
}
  • If there is any solution for equation_1 and equation_2, also there is a solution for i<=KKK-1.
  • We try all possible i values and we get a x value for equation_1. Then we check if x equals to equation_2.b+equation_2.a .
  • If this condition is true, we find a x value. // x = i*equation_1.b+equation_1.a(mod LCM)
  • If there is no x value, that means solution doesn't exist.

This algorithm's complexity is O( max( equation_i.b )*n )

  • Проголосовать: нравится
  • +35
  • Проголосовать: не нравится

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +60 Проголосовать: не нравится

It's nice that you do your own investigations, but I'm sorry to disappoint you — this is not something new, rather easy modifications of CTR (in classical CTR b values need to be coprime, not necessarily prime) and each merge can be done in O(log b) using extended Euclid's algorithm. In order to name a theorem with your name, you have to try harder :).

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Your problem is basically this one: https://open.kattis.com/problems/generalchineseremainder (If you can solve it for two numbers, you can easily solve it for N numbers by iteratively applying the algorithm.) The URL seems to suggest that we should call it "General Chinese Remainder Theorem". ^^

»
11 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится -16 Проголосовать: не нравится

Another question on CRT: Chinese and random toppings

Edit: I suggested one question on Chinese Remainder Theorem. Why downvotes?