22389_MagicBitstrings

2022-5-16 18:21| 发布者: Hocassian| 查看: 24| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506384361900-Problem List-采集的数据-后羿采集器.html

Pro.ID

22389

Title

Magic Bitstrings

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22389

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    A bitstring, whose length is one less than a prime, might be magic. 1001 is one such string. In order to see the magic in the string let us append a non-bit x to it, regard the new thingy as a cyclic string, and make this square matrix of bits

    each bit1001
    every 2nd bit0110
    every 3rd bit0110
    every 4th bit1001

    This matrix has the same number of rows as the length of the original bitstring. The m-th row of the matrix has every m-th bit of the original string starting with the m-th bit. Because the enlarged thingy has prime length, the appended x never gets used.

    If each row of the matrix is either the original bitstring or its complement, the original bitstring is magic.

    输入

    Each line of input (except last) contains a prime number p ≤ 100000. The last line contains 0 and this line should not be processed.

    输出

    Description

    A bitstring, whose length is one less than a prime, might be magic. 1001 is one such string. In order to see the magic in the string let us append a non-bit x to it, regard the new thingy as a cyclic string, and make this square matrix of bits

    each bit1001
    every 2nd bit0110
    every 3rd bit0110
    every 4th bit1001

    This matrix has the same number of rows as the length of the original bitstring. The m-th row of the matrix has every m-th bit of the original string starting with the m-th bit. Because the enlarged thingy has prime length, the appended x never gets used.

    If each row of the matrix is either the original bitstring or its complement, the original bitstring is magic.

    Input

    Each line of input (except last) contains a prime number p ≤ 100000. The last line contains 0 and this line should not be processed.

    Output

    For each prime number from the input produce one line of output containing the lexicographically smallest, non-constant magic bitstring of length p-1, if such a string exists, otherwise output Impossible.

    Sample Input

    5
    3
    17
    47
    2
    79
    0

    Sample Output

    0110
    01
    0010111001110100
    0000100001101010001101100100111010100111101111
    Impossible
    001001100001011010000001001111001110101010100011000011011111101001011110011011

    Source

    样例输入

    5
    3
    17
    47
    2
    79
    0

    样例输出

    0110
    01
    0010111001110100
    0000100001101010001101100100111010100111101111
    Impossible
    001001100001011010000001001111001110101010100011000011011111101001011110011011

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部