CF39F.Pacifist frogs

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Thumbelina has had an accident. She has found herself on a little island in the middle of a swamp and wants to get to the shore very much.

One can get to the shore only by hills that are situated along a straight line that connects the little island with the shore. Let us assume that the hills are numbered from 11 to nn and the number of a hill is equal to the distance in meters between it and the island. The distance between the nn -th hill and the shore is also 11 meter.

Thumbelina is too small to make such jumps. Fortunately, a family of frogs living in the swamp suggests to help her. Each frog agrees to give Thumbelina a ride but Thumbelina should choose only one frog. Each frog has a certain jump length. If Thumbelina agrees to accept help from a frog whose jump length is dd , the frog will jump from the island on the hill dd , then — on the hill 2d2d , then 3d3d and so on until they get to the shore (i.e. find itself beyond the hill nn ).

However, there is one more problem: mosquitoes also live in the swamp. At the moment they have a siesta, and they are having a nap on some hills. If the frog jumps on a hill with a mosquito the frog will smash it. The frogs Thumbelina has met are pacifists, so they will find the death of each mosquito very much sad. Help Thumbelina choose a frog that will bring her to the shore and smash as small number of mosquitoes as possible.

输入格式

The first line contains three integers nn , mm and kk ( 1<=n<=1091<=n<=10^{9} , 1<=m,k<=1001<=m,k<=100 ) — the number of hills, frogs and mosquitoes respectively. The second line contains mm integers did_{i} ( 1<=di<=1091<=d_{i}<=10^{9} ) — the lengths of the frogs’ jumps. The third line contains kk integers — the numbers of the hills on which each mosquito is sleeping. No more than one mosquito can sleep on each hill. The numbers in the lines are separated by single spaces.

输出格式

In the first line output the number of frogs that smash the minimal number of mosquitoes, in the second line — their numbers in increasing order separated by spaces. The frogs are numbered from 11 to mm in the order of the jump length given in the input data.

输入输出样例

  • 输入#1

    5 3 5
    2 3 4
    1 2 3 4 5
    

    输出#1

    2
    2 3
    
  • 输入#2

    1000000000 2 3
    2 5
    999999995 999999998 999999996
    

    输出#2

    1
    2
    
首页