#!/usr/bin/perl
# your code goes here
{
my @data;
$data[1] = 1; # x1 день
for (2..4) {
$data[$_] = 2; # x2-x4 дня
}
for (0, 5..9, 10..19) {
$data[$_] = 3; # x5-x0 дней
}
sub plural($$$$) {
? $_[$data[$_[0]]]
: $_[$data[$_[0] % 10]];
}
}
for (11, 21, 2, 5, 25, 30, 100501) {
printf "%d %s\n", $_, plural
($_, 'день','дня','дней'); }
IyEvdXNyL2Jpbi9wZXJsCiMgeW91ciBjb2RlIGdvZXMgaGVyZQp7CiAgICBteSBAZGF0YTsKCiAgICAkZGF0YVsxXSA9IDE7ICAgICAgICMgeDEg0LTQtdC90YwKCiAgICBmb3IgKDIuLjQpIHsKICAgICAgICAkZGF0YVskX10gPSAyOyAgIyB4Mi14NCDQtNC90Y8KICAgIH0KCiAgICBmb3IgKDAsIDUuLjksIDEwLi4xOSkgewogICAgICAgICRkYXRhWyRfXSA9IDM7ICAjIHg1LXgwINC00L3QtdC5CiAgICB9CgogICAgc3ViIHBsdXJhbCgkJCQkKSB7CiAgICAgICAgcmV0dXJuICRfWzBdIDwgMjAKICAgICAgICAgICAgPyAkX1skZGF0YVskX1swXV1dCiAgICAgICAgICAgIDogJF9bJGRhdGFbJF9bMF0gJSAxMF1dOwogICAgfQp9Cgpmb3IgKDExLCAyMSwgMiwgNSwgMjUsIDMwLCAxMDA1MDEpIHsKICAgIHByaW50ZiAiJWQgJXNcbiIsICRfLCBwbHVyYWwoJF8sICfQtNC10L3RjCcsJ9C00L3RjycsJ9C00L3QtdC5Jyk7Cn0=