ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1082. Gaby Ivanushka

analysis
Posted by OvO 24 May 2011 11:08
let sequence be 1,2,3,...,n

I.    in each P( l, r ) there will be 1 + r-l+1 times ++ c.

II.   in each Q( l, n ) = Q( l, l ) there will be 0 time ++ c.

III.  in each Q( n, r ) = Q( n+1, r ) + P( n, r ).

IV.   Let F( n ) is the total times of ++ c, so we get F( n ) = F( n-1 ) + n + 1 and F( 1 ) = Q( r, r ) = 0;

the sum of ++ c is 3 + 4 +... + n+1 = n*(n-1)/2 + 2*(n-1) = (n-1)*(n+4)/2 = (n*n+3*n-4)/2

Edited by author 24.05.2011 11:12

Edited by author 24.05.2011 11:13
Re: analysis
Posted by Lyzhin Vladimir 22 Jan 2013 21:25
What the fucking analysis do you do?
Simply solve the quadratic equation in the IF condition "if(c==(N*N+3*N-4)/2)", and you will see that with any nonnegative value of "c" the program will print out "Beutiful Vasilisa".
The variable "c" will be nonnegative in any case, because of the initial value = 0, and increment operator.
Re: analysis
Posted by Andrey Lopukhov 10 Jul 2013 18:47
I guess u read "if(c=(N*N+3*N-4)/2)" instead of "if(c==(N*N+3*N-4)/2)"
Re: analysis
Posted by naik 24 Mar 2014 02:02
Я вывел формулу по другому:

n*(n+1)/2 - 1 + (n - 1) = n*(n+1)/2 + (n - 2) = (n*n + 3*n - 4) / 2

n*(n+1)/2 - кол-во проверок на возрастание
-1 - вычитаем один случай, когда остался один элемент
(n - 1) - кол-во проверок на убывание