Fixed points P34682


Statement
 

pdf   zip

Let S=x1,,xnS = x_1, \dots, x_n be a sequence of integer numbers such that x1<<xnx_1 < \dots < x_n. For every integer number aa and every index 1in1 \le i \le n, define fa(i)=xi+af_a(i) = x_i + a. Write a program that, given SS and aa, tells whether there is some ii such that fa(i)=if_a(i) = i.

Input

Input consists of several cases. Every case begins with nn, followed by SS, followed by a number mm, followed by mm different integer numbers a1,,ama_1, \dots, a_m. Assume 1n1061 \le n \le 10^6.

Output

For every case, print its number starting at 1. Afterwards, for every aja_j 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