시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 128 MB197514742.342%

문제

두 정수가 만약에 완전히 같은 숫자들로만 이루어져 있으면 두 숫자를 friends(친구)라고 부른다. 예를 들어 123과 32331313323213은 friends 이지만 123과 22121221은 아니다.

그러나 friends가 아닌 두 개의 정수가 만약에 이웃한 두 숫자를 규칙에 따라 고쳤을 때 friends가 되면 almost friends(거의 친구)라고 부른다. 그 규칙은 만약에 a와 b가 붙어 있으면 a에 1을 빼고 b에 1을 더하거나 a에 1을 더하고 b에 1을 뺄 수 있다는 것이다. 하지만 그 결과에서 맨 앞자리 숫자가 0이라면 이것은 허용이 되지 않는다. 예를 들어 123과 2223042는 almost friends이다. (2223042 -> 2223132) 하지만 137과 470은 friends도 almost friends도 아니다. (137 -> 047)은 허용이 되지 않는다. 연산은 두 수 중 하나에게만, 최대 한 번 사용할 수 있다.

만약에 두 정수가 주어져 있을 때, 두 정수가 friends인지, almost friends인지, 아니면 아무것도 아닌지 구하는 프로그램을 작성하시오.

입력

세 개의 입력 데이터가 주어지며, 각각의 입력 데이터는 한 개의 줄로 이루어져 있다. 각 데이터의 첫째 줄에 두 정수 x, y가 공백을 사이에 두고 주어진다.

출력

세 개의 줄에 걸쳐 입력된 순서대로 x, y가 friends면 “friends", almost friends이면 ”almost friends", 둘 다 아니면 “nothing" 이라고 출력한다.

제한

  • 0 < x, y < 10100
  • x, y는 0으로 시작하지 않는다.

예제 입력 1

123 32331313323213
137 470
123 2223042

예제 출력 1

friends
nothing
almost friends
W3sicHJvYmxlbV9pZCI6IjE5ODUiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWI1MTRcdWM5YzBcdWQxMzggXHVjZTVjXHVhZDZjIiwiZGVzY3JpcHRpb24iOiI8cD5cdWI0NTAgXHVjODE1XHVjMjE4XHVhYzAwIFx1YjljY1x1YzU3ZFx1YzVkMCBcdWM2NDRcdWM4MDRcdWQ3ODggXHVhYzE5XHVjNzQwIFx1YzIyYlx1Yz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HV0IjoiPHA+VGhlIGZyaXN0IGxpbmUgb2YgdGhlIGlucHV0IGNvbnRhaW5zIGEgc2luZ2xlIG51bWJlcjogdGhlIG51bWJlciBvZiB0ZXN0IGNhc2VzIHRvIGZvbGxvdy4gRWFjaCB0ZXN0IGNhc2UgaGFzIHRoZSBmb2xsb3dpbmcgZm9ybWF0OiZuYnNwOzxcL3A+XHJcblxyXG48cD5PbmUgbGluZSB3aXRoIHR3byBpbnRlZ2VyIHggYW5kIHksIHNlcGFyYXRlZCBieSBhIHNpbmdsZSBzcGFjZSwgd2l0aCAwICZsdDsgeCwgeSAmbHQ7IDEwPHN1cD4xMDA8XC9zdXA+LiBCb3RoIGludGVnZXJzIHN0YXJ0IHdpdGggYSBub24temVybyBkaWdpdC4mbmJzcDs8XC9wPlxyXG4iLCJvdXRwdXQiOiI8cD5Gb3IgZXZlcnkgdGVzdCBjYXNlIGluIHRoZSBpbnB1dCwgdGhlIG91dHB1dCBzaG91bGQgY29udGFpbiBhIHNpbmdsZSBsaW5lIHdpdGggdGhlIHN0cmluZyAmcXVvdDtmcmllbmRzJnF1b3Q7IG9yICZxdW90O2FsbW9zdCBmcmllbmRzJnF1b3Q7IG9yICZxdW90O25vdGhpbmcmcXVvdDssIHJlZmxlY3RpbmcgdGhlIHByb3BlcnR5IG9mIHRoZSB0d28gZ2l2ZW4gaW50ZWdlcnMmbmJzcDs8XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwiaHRtbF90aXRsZSI6IjAiLCJwcm9ibGVtX2xhbmdfdGNvZGUiOiJFbmdsaXNoIn1d

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2006 D번