The answer depends upon the ranges from which the numbers are chosen.

The unique solution for the ranges 2,62? through 2,500+? is

SUM PRODUCT X Y

17 52 4 13

The unique solution for the ranges 3,94? through 3,500+? is

SUM PRODUCT X Y

29 208 13 16

There are no unique solutions for the ranges starting with 1, and there are no solutions for ranges starting with numbers above 3.

A program to compute the possible pairs is included below.

1. include <stdio.h>

/*

BEGINNING OF PROBLEM STATEMENT: Mr. S. and Mr. P. are both perfect logicians, being able to correctly deduce any truth from any set of axioms. Two integers (not necessarily unique) are somehow chosen such that each is within some specified range. Mr. S. is given the sum of these two integers; Mr. P. is given the product of these two integers. After receiving these numbers, the two logicians do not have any communication at all except the following dialogue:

<<1>> Mr. P.: I do not know the two numbers. <<2>> Mr. S.: I knew that you didn't know the two numbers. <<3>> Mr. P.: Now I know the two numbers. <<4>> Mr. S.: Now I know the two numbers.

Given that the above statements are true, what are the two numbers?

END OF PROBLEM STATEMENT

• /
1. define SMALLEST_MIN 1
2. define LARGEST_MIN 10
3. define SMALLEST_MAX 50
4. define LARGEST_MAX 500

long P(LARGEST_MAX + 1) * (LARGEST_MAX + 1)?; /* products / long S(LARGEST_MAX + 1) + (LARGEST_MAX + 1)?; / sums */

find(long min, long max) {

long i, j; /*

• count factorizations in P[]
• all Pn? > 1 satisfy <<1>>.
• /

for(i = 0; i <= max * max; ++i)

Pi? = 0;

for(i = min; i <= max; ++i)

for(j = i; j <= max; ++j)

• +Pi * j?;

/*

• decompose possible SUMs and check factorizations
• all Sn? == min - 1 satisfy <<2>>.
• /

for(i = min + min; i <= max + max; ++i) {

for(j = i / 2; j >= min; --j)

if(Pj * (i - j)? < 2)

break;

Si? = j;

}

/*

• decompose SUMs which satisfy <<2>> and see which products
• they produce. All (Pn? / 1000 == 1) satisfy <<3>>.
• /

for(i = min + min; i <= max + max; ++i)

if(Si? == min - 1)

for(j = i / 2; j >= min; --j)

if(Pj * (i - j)? > 1)

Pj * (i - j)? += 1000;

/*

• decompose SUMs which satisfy <<2>> again and see which products
• satisfy <<3>>. Any (Sn? == 999 + min) satisfies <<4>>
• /

for(i = min + min; i <= max + max; ++i)

if(Si? == min - 1)

for(j = i / 2; j >= min; --j)

if(Pj * (i - j)? / 1000 == 1)

Si? += 1000;

/*

• find the answer(s) and print them
• /

printf("%d,%d?\n",min,max); for(i = min + min; i <= max + max; ++i)

if(Si? == 999 + min)

for(j = i / 2; j >= min; --j)

if(Pj * (i - j)? / 1000 == 1)

printf("{ %d %d }: S = %d, P = %d\n",

i - j, j, i, (i - j) * j);

}

main() {

long min, max;

for (min = SMALLEST_MIN; min <= LARGEST_MIN; min ++)

for (max = SMALLEST_MAX; max <= LARGEST_MAX; max++)

find(min,max);

}

= Jeff Kenton (617) 894-4508 = = jkenton@world.std.com =

lib/config.php:156: Notice: Undefined variable: accept

lib/DbaDatabase.php:154: Warning: dba_optimize() [<a href='function.dba-optimize'>function.dba-optimize</a>]: You cannot perform a modification to a database without proper access