Card game
Program file name
: card.cpp / card.pas / ...
NKPC
The players of the competition and Xiao Li often play a small game.
This game rule is simple
:
Xiaojin is holding in the hand
N
The card is written, and a positive integer is written on each card.
Xiao Li knows that the number of cards is different, but he doesn't know which one is the maximum.
At the beginning of the game, Xiao Jin alone took a card to Xiao Li, and asked Xiao Li.
"
Is this number bigger?
"
.
If Xiao Li replied
"
Yes
"
Then the game is ending; otherwise, a small re-draw a different card, repeat the above problems.
When only the last card left in the small gold hand,
So Xiao Li can only answer
"
Yes
"
.
If Xiao Li is just guessing the biggest value, that is, when Xiao Jin took the largest number, Xiao Li replied
"
Yes
"
He won.
recent
,
Xiao Li came up with a good way to find the biggest value:
For the first one to the first
M (1 <= m Zhang card is answered " Do not " ; Then, from the first M 1 Zhang begins, if the number on the current card is larger than the previously owned number , So answer " Yes " Otherwise answer " Do not " . Maybe you have noticed , How is the most important thing in the method of Xiao Li? M Value. Your goal is to make a program to help Xiao Li found the best. M value , Let Xiao Li win this game with the biggest probability. enter (Please use standard input and output, not to read and write) Only one integer N (3 <= n <= 100000) Output (Please use standard input and output, not to read and write) Output is an integer M , Indicating the maximum probability of winning the effectiveness M . Sample input 1 Sample output 1 3 1 Sample input 2 Sample output 2 5 2 #include #define Number 100000INT A [Number] [100]; int N = 1000; int N = 5; Void initiala () {TIME_T T; T = Time (null); clock_t goal; srand (unsigned) T); for (int i = 0; i <100; i ) {for (int J = 0; J BOOL CMPI (INT I, INT M) // Treatment A [i], prior M. {INT mmax, max = 0; BOOL FLAG = false; mmax = a [i] [0]; for (int J = 1 J INT DEALM (INT M) // Successful number of m-numbered {int SUC = 0; for (int i = 0; i Void main () {int index = 0; int big = 0; int Temp = 0; char CH [10]; MEMSET (CH, 0, 10); Clock_t Goal; Cout << "Initialization Sequence ... << Endl; initiala (); cout << "input N, (1