Fixed points P34682


Statement
 

pdf   zip

thehtml

Let S = x1, …, xn be a sequence of integer numbers such that x1 < … < xn. For every integer number a and every index 1 ≤ in, define fa(i) = xi + a. Write a program that, given S and a, tells whether there is some i such that fa(i) = i.

Input

Input consists of several cases. Every case begins with n, followed by S, followed by a number m, followed by m different integer numbers a1, …, am. Assume 1 ≤ n ≤ 106.

Output

For every case, print its number starting at 1. Afterwards, for every aj print the position of its fixed point. If no fixed point exists, state so. If there is more than one fixed point, print the smallest one. Print a blank line after the output for every case.

Public test cases
  • Input

    5
    -7 -2 0 4 8
    1
    0
    
    5
    0 1 2 3 4
    3
    0 -1 1
    

    Output

    Sequence #1
    fixed point for 0: 4
    
    Sequence #2
    no fixed point for 0
    no fixed point for -1
    fixed point for 1: 1
    
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++ Python
    User solutions
    C C++ Python