DWITE '10 R1 #3 - Power tiles

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
DWITE Online Computer Programming Contest, October 2010, Problem 3

You are given a rectangular floor that is to be tiled with square tiles. The tiles come in a variety of sizes, but they all measure in some power of two: 1, 2, 4, 8, etc. A 5 \times 6 space can be tiled with 30 of the smallest tile, but the minimum number of tiles required is only 9. Refer to the pattern below.

The input will contain 5 lines, a pair of integers 1 \leq N, M \leq 10\,000, separated by a space.

The output will contain 5 lines, the minimum number of tiles necessary to exactly cover the N by M space.

Sample Input

10 5
1000 1001
21 13
9999 888
345 1277

Sample Output


Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) Problem Resource: DWITE


  • -1
    Plasmatic  commented on Aug. 22, 2018, 6:15 p.m.

    y'all and your fancy recursion solutions :v :v