File name and extension
Time: 1 s · Memory: 256 MB
- Strings
Statement
You are given the full path of a file, for example /home/ali/books/My_book.pdf: directories are separated by / and the file name comes last. The part of the file name after the last dot is the extension, the part before it is the name. Find the name and the extension.
Input format
A single line with the path — up to characters, starting with /, without spaces. The file name contains at least one dot; the name and the extension are not empty. Directory names may contain dots too.
Output format
A single line with two strings: the name and the extension.
Examples
Input
/home/ali/books/My_book.pdf
Output
My_book pdf
Input
/arxiv.tar.gz
Output
arxiv.tar gz
Note
First extract the file name — the part after the last / — then find the last . in it. The order matters: in /my.dir/file.txt the first dot of the path belongs to a directory. In the second example: arxiv.tar gz.
