Logo
(追記) (追記ここまで)

11839번 - Beautiful row 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 256 MB74322946.774%

문제

Ali-Amir wrote N numbers in a row. A row is called beautiful if any two of the neighbour numbers in the row have got the same amount of ones in binary or ternary notations.

Ali-Amir wants to count the number of ways the all given numbers can be written in a beautiful row.

입력

The first line of input file contains integer N (2 ≤ N ≤ 20). The next line contains N non-negative integers not exceeding 109 each.

출력

Output the number of ways the all given numbers can be placed in a beautiful row.

제한

예제 입력 1

3
5 1 6

예제 출력 1

2

힌트

In the sample 5 = 123 and 1 = 13, 5 = 1012 and 6 = 1102, thus rows 1 5 6 and 6 5 1 are beautiful.

출처

Olympiad > International Zhautykov Olympiad > IZhO 2012 B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /