11312 - Flipping Frustration

All about problems in Volume 113. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
Tomato
New poster
Posts: 5
Joined: Sun Oct 21, 2007 3:27 am

11312 - Flipping Frustration

Post by Tomato »

I got that this problem is solved using diophant's method. In case the given test case has a solution and after we get a general solution for x (number of left flips) and y (number of right flips), how shall we get the minimum one?
pineapple
Learning poster
Posts: 57
Joined: Fri Nov 03, 2006 3:33 pm

Re: 11312 - FLIPPING FRUSTRATION

Post by pineapple »

Tomato wrote:I got that this problem is solved using diophant's method. In case the given test case has a solution and after we get a general solution for x (number of left flips) and y (number of right flips), how shall we get the minimum one?
It is trivial and similar with problem 10090.I suggest you solve it firstly.
1)x<0 && y>0,you can get the maximum x<=0 by add some multiple to x.
2)x>0 && y<0,you can get the maximum x<=0 by sub some multiple to x.
The hardest part of this problem is how to fit the tricky boundary.
Hope it helps.
Donotalo
Learning poster
Posts: 56
Joined: Sat Aug 20, 2005 11:05 am
Location: Bangladesh

Post by Donotalo »

I tried the following:
Input:

Code: Select all

9
10 5 4 1
1000 2 1 42
100 2 4 66
101 60 70 51
100 2 3 98
10000000 1 1 10000000
35 3 10 35
35 3 10 34
29 13 5 29
Output:

Code: Select all

0
41
uh-oh!
uh-oh!
34
9999999
6
15
uh-oh!
Seems correct to me. Are they wrong? Can anyone give me tricky I/O? Please help.

Thanks.
Image
pineapple
Learning poster
Posts: 57
Joined: Fri Nov 03, 2006 3:33 pm

Post by pineapple »

my code output 20 for your last case.
others are same.
hope it helps
sonyckson
New poster
Posts: 49
Joined: Tue Feb 06, 2007 9:29 pm
Location: Cordoba, Argentina

Post by sonyckson »

pineapple wrote:"The hardest part of this problem is how to fit the tricky boundary. "
I see, i have more than 20 WA.... and i still cant realize an efficient way to know if my numbers will not exceed the number of pages of the book, i mean, i have the minimum x and y ( the minimum sum ) , such that doing x left flip's and y right flips, i can arrive to the page i need, but i dont know if those flips, are feasible with the number of pages of the book. Any hints?? thanks!, Eric.
Post Reply

Return to “Volume 113 (11300-11399)”