Guess numbers

xiaoxiao2021-03-06  52

From 2 to 100, there are 99 numbers, and two numbers have been drawn, and these two numbers tell A, and they tell B. The following is a conversation of these two: A: I don't know which two numbers, but I am sure you don't know. After era, I heard it slightly, say: I didn't know which two numbers were it, but now I know. After listening, first, then do it, say: Oh, I also know. Excuse me: Which two numbers are extracted?

///

A summary description of /// guess2.

///

/// use J to represent A, Y Represents B.

/// Let's first put all the situations of Junknowandjknowyunknow (A Knowledge and Kerry By B.

///

///

Public Class Guess2

{

Public guess2 ()

{

//

// TODO: Add constructor logic here

//

THIS.INITARRAYLIST ();

THIS.output ();

}

Public static int number = 100; private arraylist arrayjunknownowndjknowyunknow;

///

/// Get all Number of JunkNowndjknowyunknow

/// 歌德 巴 德 (大 偶 数 等 于 质 之) Although it is not fully proven,

/// / / tens of billion, there is a poor, if it may be a big number, the armor cannot conclude B must not know.

///

Private void initarraylist ()

{

THIS.Arrayjunknowandjknowyunknow = new arraylist ();

For (int i = 7; i <2 * number - 1; i = i 2)

{

IF (this.junknowandjknowyunknow (i))

THIS.Arrayjunknowandjknowyunknow.add (i);

}

}

Public void print (int x, int y) {console.writeLine ("x =" x "y =" y);

///

/// Ah doesn't know what the numbers are

/// of the two and greater than or equal to 7, less than or equal to 197

///

Public Bool JunkNow (int SUM)

{

IF (SUM <= Number * 2 - 1 && sum> = 7)

Return True;

Return False;

}

///

/// B is not knowing what the numbers are.

/// There are more than 3 or more than 1 and itself)

/// There are more than two of the averages from 2 to this number

///

///

Public Bool YunkNow (int S)

{

INT count = 0;

For (int i = 2; i <= number && i <= math.sqrt (s); i )

{

IF (S% i == 0 && S / i <= number) //

{

COUNT ;

}

IF (count> 1) // indicates that there are two compliance above

Return True;

}

Return False;

}

///

/// A knew that B did not know, split the SUM value. List all possible.

///

///

///

Public bool jknowyunknow (int sum) {

For (int I = 2; i

{

IF (SUM - I> 100)

CONTINUE;

INT S = I * (SUM - I);

IF (! YunkNow (s))

Return False;

}

Return True;

}

///

/// The armor does not know, and the A Know B is not known.

///

///

///

Public Bool Junknowandjknowyunknow (int SUM)

{

IF (JunkNow && JknowyunkNow (SUM))

{

Return True;

}

Return False;

}

///

/// The then B knows

///

///

///

Public Bool ThenykNow (int S)

{

INT count = 0;

INT X, Y;

// Enumerate, take the moisture

For (int i = 2; I

{

IF (s% i == 0)

{

y = i;

X = S / I;

IF (this.Arrayjunknowandjknowyunknow.contains (x y))

{

COUNT ;

}

}

}

IF (count == 1)

Return True;

Else

Return False;

}

///

/// The last one knows

///

///

///

Public Bool JknowLast (int SUM)

{

IF (! this.Arrayjunknowandjknowyunknow.contains (sum))

{

Return False;

}

INT count = 0;

For (int I = 2; i

{

INT S = I * (SUM - I);

IF (THENYKNOW (S))

COUNT ;

}

IF (count == 1)

Return True;

Return False;

}

///

/// Print results

///

Public void output ()

{

Console.writeline ("------- Guess 2 --------");

// foreach (int I in this.Arrayjunknowndjknowyunknow)

// {

// console.writeline (i);

//}

For (int x = 2; x <= number; x ) {for (int y = 2; y

转载请注明原文地址:https://www.9cbs.com/read-118041.html

New Post(0)