#P6843. Absolute File Path Length
Absolute File Path Length
Absolute File Path Length
Consider a file named file that is stored in a directory tree. Its absolute file path has the form \( /dir_1/dir_2/\cdots/dir_j/file \), with the root directory represented by /. In particular, if a file is located directly in the root directory its path is /file.
A symbolic link is a shortcut that points to a named directory (note that a symbolic link cannot point to a file) and can be placed anywhere. For instance, if we place a symbolic link named hello (whose name length is \(s\)) in the root directory that points to /, then the paths /dir/file, /hello/dir/file, /hello/hello/dir/file all refer to the same file file. Similarly, if we place in /dir a symbolic link hi that points to /, then /dir/file, /dir/hi/dir/file, and /dir/hi/dir/hi/dir/file all refer to the same file.
Note that a symbolic link can point to a directory in the same layer, a lower layer or an upper layer. However, operations like ./, ../ or // are not allowed.
The question is: by introducing one symbolic link whose name has length \(s\), is it possible to construct an absolute file path (which eventually accesses file) whose total length is exactly \(k\)?
The absolute file path is built from components. It always begins with a slash / (count as 1 character) and ends with the file name file (4 characters). Between them, there may be zero or more directory names separated by a slash. For a directory that is not a symbolic link we assume its name is dir (3 characters) so that its representation along with the preceding slash contributes \(1+3=4\) characters. A symbolic link placed anywhere contributes \(1+s\) characters (1 for the preceding slash and \(s\) for its name).
Thus, if we use \(a\) regular directories and \(b\) occurrences of the symbolic link, the total length \(L\) of the absolute path is:
\[ L = 5 + 4a + (s+1)b \]where the 5 comes from the leading slash and the file name (/file is 5 characters). We are given \(s\) and \(k\), and we want to know if there exist nonnegative integers \(a\) and \(b\) satisfying:
If such a solution exists, output Yes; otherwise, output No.
inputFormat
The input consists of a single line containing two integers \(s\) and \(k\) (with \(s \ge 1\) and \(k \ge 1\)). \(s\) is the length of the symbolic link's name and \(k\) is the required total length of the absolute file path.
outputFormat
Output Yes if it is possible to construct an absolute file path of length exactly \(k\) using the available building blocks, otherwise output No.
sample
5 5
Yes
</p>