import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
class TesteRegex {
private static final Pattern PERC_PAT =
Pattern.compile("(?:[1-9]|[1-9][0-9]|100)%?");
if (in == null) return "";
for (String s
= in
; !s.
isEmpty(); s
= s.
substring(0, s.
length() - 1)) { if (PERC_PAT.matcher(s).matches()) return s;
}
return "";
}
public static void main
(String[] args
) { List<String> s = new ArrayList<>();
s.add("");
s.add("%");
s.add("x");
for (int i = 0; i < 100; i++) {
s.add(i + "");
s.add(i + "%");
s.add(i + "x");
}
for (int i = 0; i < 11; i++) {
s.add(i + "00");
s.add(i + "00%");
s.add(i + "00x");
s.add(i + "01");
s.add(i + "01%");
s.add(i + "01x");
s.add("0" + i);
}
System.
out.
println(ss
+ ": " + format
(ss
)); }
}
}
aW1wb3J0IGphdmEudXRpbC5BcnJheUxpc3Q7CmltcG9ydCBqYXZhLnV0aWwuTGlzdDsKaW1wb3J0IGphdmEudXRpbC5yZWdleC5QYXR0ZXJuOwoKY2xhc3MgVGVzdGVSZWdleCB7CgkKICAgIHByaXZhdGUgc3RhdGljIGZpbmFsIFBhdHRlcm4gUEVSQ19QQVQgPQogICAgICAgICAgICBQYXR0ZXJuLmNvbXBpbGUoIig/OlsxLTldfFsxLTldWzAtOV18MTAwKSU/Iik7CgogICAgcHJpdmF0ZSBzdGF0aWMgU3RyaW5nIGZvcm1hdChTdHJpbmcgaW4pIHsKICAgICAgICBpZiAoaW4gPT0gbnVsbCkgcmV0dXJuICIiOwogICAgICAgIGZvciAoU3RyaW5nIHMgPSBpbjsgIXMuaXNFbXB0eSgpOyBzID0gcy5zdWJzdHJpbmcoMCwgcy5sZW5ndGgoKSAtIDEpKSB7CiAgICAgICAgICAgIGlmIChQRVJDX1BBVC5tYXRjaGVyKHMpLm1hdGNoZXMoKSkgcmV0dXJuIHM7CiAgICAgICAgfQogICAgICAgIHJldHVybiAiIjsKICAgIH0KCiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgTGlzdDxTdHJpbmc+IHMgPSBuZXcgQXJyYXlMaXN0PD4oKTsKICAgICAgICBzLmFkZCgiIik7CiAgICAgICAgcy5hZGQoIiUiKTsKICAgICAgICBzLmFkZCgieCIpOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgMTAwOyBpKyspIHsKICAgICAgICAgICAgcy5hZGQoaSArICIiKTsKICAgICAgICAgICAgcy5hZGQoaSArICIlIik7CiAgICAgICAgICAgIHMuYWRkKGkgKyAieCIpOwogICAgICAgIH0KICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IDExOyBpKyspIHsKICAgICAgICAgICAgcy5hZGQoaSArICIwMCIpOwogICAgICAgICAgICBzLmFkZChpICsgIjAwJSIpOwogICAgICAgICAgICBzLmFkZChpICsgIjAweCIpOwogICAgICAgICAgICBzLmFkZChpICsgIjAxIik7CiAgICAgICAgICAgIHMuYWRkKGkgKyAiMDElIik7CiAgICAgICAgICAgIHMuYWRkKGkgKyAiMDF4Iik7CiAgICAgICAgICAgIHMuYWRkKCIwIiArIGkpOwogICAgICAgIH0KICAgICAgICBmb3IgKFN0cmluZyBzcyA6IHMpIHsKICAgICAgICAJU3lzdGVtLm91dC5wcmludGxuKHNzICsgIjogIiArIGZvcm1hdChzcykpOwogICAgICAgIH0KICAgIH0KfQ==