• [E] Prime Again

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • We all vary familar with prime numbers, now we get a integer N(1<=n <= 16), for 1 to N, your task is to write a
    Cyclic sequences a1~an, all numbers only use once, and every sum of adjacent two numbers should be prime. No matter how you cut a circle, they're just the same, so one circle should be print only once. For all results, we print by lexicographical order. If there's no answer, you needn't print anything.
  • 输入
  • There are many cases, end until EOF, each a integer N(1<=n <= 16) in a single line.
  • 输出
  • Please prnit by lexicographical order.
  • 样例输入
  • 4
    6
    
  • 样例输出
  • 1 2 3 4
    1 4 3 2
    1 4 3 2 5 6
    1 6 5 2 3 4
    
  • 提示
  • 来源
  • Minary
  • 操作

显示春菜