CF39F.Pacifist frogs
普及-
通过率:0%
时间限制:2.00s
内存限制:64MB
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 1 to n and the number of a hill is equal to the distance in meters between it and the island. The distance between the n-th hill and the shore is also 1 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 d, the frog will jump from the island on the hill d, then — on the hill 2_d_, then 3_d_ and so on until they get to the shore (i.e. find itself beyond the hill n).
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.
拇指姑娘出了意外。她发现自己被困在沼泽中央的一座小岛上,非常渴望抵达岸边。
唯一能到达岸边的方式是借助一排位于小岛与岸边连线上、呈直线排列的小山丘。我们假设这些山丘编号为 1 到 n,且某座山丘的编号即表示它与小岛之间的距离(单位:米)。第 n 座山丘与岸边之间的距离也为 1 米。
拇指姑娘体型太小,无法独自完成如此远的跳跃。幸运的是,生活在沼泽中的一群青蛙愿意帮助她。每只青蛙都同意载拇指姑娘一程,但拇指姑娘只能选择其中一只青蛙。每只青蛙具有固定的跳跃长度。若拇指姑娘选择跳跃长度为 d 的青蛙,则该青蛙将从岛屿出发,首先跳到编号为 d 的山丘上,接着跳到编号为 2d 的山丘上,再跳到编号为 3d 的山丘上……如此继续,直到抵达岸边(即跳至编号大于 n 的位置)。
然而,还有一个问题:沼泽中还生活着蚊子。此时它们正在午睡,正趴在某些山丘上休息。如果青蛙跳到了有蚊子的山丘上,就会把蚊子压死。而拇指姑娘遇到的这些青蛙都是和平主义者,因此每只青蛙都会为每只被压死的蚊子深感悲伤。请帮助拇指姑娘选择一只青蛙,使她能成功抵达岸边,同时压死的蚊子数量尽可能少。
输入格式
The first line contains three integers n, m and k (1 ≤ n ≤ 109, 1 ≤ m, k ≤ 100) — the number of hills, frogs and mosquitoes respectively. The second line contains m integers d__i (1 ≤ d__i ≤ 109) — the lengths of the frogs’ jumps. The third line contains k 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.
第一行包含三个整数 n、m 和 k(1 ≤ n ≤ 109,1 ≤ m, k ≤ 100),分别表示山丘的数量、青蛙的数量和蚊子的数量。
第二行包含 m 个整数 di(1 ≤ di ≤ 109),表示每只青蛙的跳跃长度。
第三行包含 k 个整数,表示每只蚊子所栖息的山丘编号。每座山丘上至多有一只蚊子。
各行中的数字以单个空格分隔。
输出格式
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 1 to m in the order of the jump length given in the input data.
第一行输出砸死蚊子数量最少的青蛙的只数;
第二行按升序输出这些青蛙的编号,编号之间用空格分隔。
青蛙按输入数据中跳跃长度的顺序编号,编号从 1 到 m。
输入输出样例
输入#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
输入解题思路,AI测评打分。不知道怎么写?