Data Mining
Time limit1sMemory limit128 MB
Choose non-negative shifts A and B so the floor formula for Q's offsets packs N records of size S_Q without overlap, minimizing the required K, then A, then B.
- Level
Hard8 of 10
- Topics
- Math, Number theory, Binary search, Brute force
- Solved
- No attempts yet
Problem
Dr. Tuple is developing a new data-mining application for a commercial merchandise company. One of its subroutines works with two arrays and , each holding records (records are numbered from to ). Array holds a hash-like structure of keys and is used to locate a record; the data of that record is then read from array .
Every record in has size bytes and every record in has size bytes. This subroutine is a hot spot of the whole application, so it must run as fast as possible. Because and are known only at run time, several compile-time optimizations become impossible.
The byte offset of the -th record is normally computed as
Multiplication is much slower than addition on modern processors, so while scanning array Dr. Tuple keeps the byte offset instead of the index , and moves to a neighbouring record with or .
Whenever a record of is located, the matching record of must be read, which needs its offset . From the two formulas above one gets
This contains both a multiplication and a (slow) integer division. To avoid them, Dr. Tuple uses the fast formula
where and are non-negative integers, is a left shift by bits (i.e. ) and is a right shift by bits (i.e. ). Assume the registers are wide enough that overflow never occurs. Since , this equals
For most choices of and this does not equal , but it can still be used at the cost of some extra memory. A conventional layout of needs bytes. Dr. Tuple can always pick a (with ) such that, if bytes are allocated for and , are chosen carefully, the fast formula stores the records without overlap: record occupies the byte range , all ranges are pairwise disjoint, and they all fit inside .
Write a program that finds the minimal together with the corresponding and . If several pairs give the same minimal , output the one with the smallest ; if there is still a tie, output the one with the smallest .
Input
The input contains three integers , , and separated by spaces (, , ).
Output
Print a single line with three integers , , and separated by spaces.