当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3055:Digital Friends

题目描述
Two positive integers are called friends if they consist of the same decimal digits. So 123 and 32331313323213 are friends, but 123 and 22121221 are not.

Two positive integers (that are not friends) are called almost friends if a single neighbour exchange in one of them results in a pair of friends. A neighbour exchanges two neighbouring digits a and b into a-1 and b+1, or into a+1 and b-1, provided that these new digits are still in the range 0...9, and that no leading zero is generated. So 123 and 2223042 are almost friends(let 04->13), and 137 and 470 are neither friends nor almost friends(note that 13 -> 04 is not allowd).
The problem is to determine if two given integers are friends or almost friends.
输入解释
The frist line of the input contains a single number: the number of test cases to follow. Each test case has the following format:
One line with two integer x and y, separated by a single space, with 0 < x, y < 10100.Both integers start with a non-zero digit.
输出解释
For every test case in the input, the output should contain a single line with the string "friends" or "almost friends" or "nothing", reflecting the property of the two given integers
输入样例
4
123 32331313323213
123 22121221
123 223042
137 470
输出样例
friends
almost friends
almost friends
nothing

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3055

最后修改于 2020-10-29T06:51:23+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536