Can I print my picture on {A,B,C}{0-10} paper? The task is to find the smallest paper size on which it is possible to print a picture of the dimensions given in milimetres. The image will be printed without margins.
Input:
Two integers (bigger than zero) and a letter a, b, or c, for example:
290
200
A

Output:
Paper size, for example:

A4

Another examples:
218,297,a      A3
1,1,c          C10
9999,9999,c    ??? (error)
74,52,A        A8
31,44,B        B10
26,1100,A       A0
250,177,b     b4
250,176,b    b5
1189,841,a    a0

The dimensions of the paper for \$i \in \{0,\dots, 10\} \$ are:
$$ \left( \frac{\alpha}{\sqrt{2}^{i+1}} , \frac{\alpha}{\sqrt{2}^{i}} \right) $$
where \$\alpha\$ depends on the type of paper:
$$ 
\begin{eqnarray} 
\alpha_A &amp;=&amp; 2 ^ {1/4} \\
\alpha_B &amp;=&amp; 2 ^ {1/2} \\
\alpha_C &amp;=&amp; 2 ^ {3/8} \\
\end{eqnarray} 
$$


Upper- and lowercase variants of letters &quot;A&quot;, &quot;B&quot; and &quot;C&quot; are
allowed on input and on output. You need to handle both of them.
The image can be printed vertically or horizontally.
The values can be passed as a parameter or entered by the user.
Width and height of picture will be always &gt; 0 (and they will be always integers), and letters will be always 'a', 'b', or 'c'. You don't need to validate them.
You need to handle paper sizes A0 - A10, B0 - B10 and C0 - C10. If the image is too large, you can throw an exception, print an error or whatever you want, as long as it is clearly different from valid result and the application will not hung up.

Paper sizes, please ignore inch values (source: Wikipedia) :


This is code-golf - fewest bytes wins.
Charcoal, 38 bytes
η⊞θ×⌊θ₂²Ｉ⊖Ｌ↨⌊Ｘ∕×φＸ²∕⁺²⌕ACB↥η⁸⁻⌈θ·²¦²¦²

Try it online! Link is to verbose version of code. Takes input as a pair of integers and a characters. Explanation:
η

Output the paper letter.
⊞θ×⌊θ₂²

Multiply the smaller dimension by √2 and use that if it is larger than the larger dimension.
Ｉ⊖Ｌ↨⌊Ｘ∕×φＸ²∕⁺²⌕ACB↥η⁸⁻⌈θ·²¦²¦²

Calculate the largest size of paper, divide by the larger dimension (less 0.2 due to rounding errors), square the result, convert to binary, and count the digits (because Charcoal has no logarithm function).