[BOJ 11492] Milestone Counter
View as PDF
Submit solution
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text
Points:
2
Time limit:
1.0s
Memory limit:
256M
Problem types
Allowed languages
Driving through the Irish countryside, one frequently sees enigmatic small grey stones sitting by the wayside, spaced about a kilometre and a half apart. As it turns out, these stones once had a purpose: they were milestones, intended to demarcate this venerable unit of measurement.</p>
Being so old and, crucially, collectible by magpies and larger scamps alike, not all of these stones have remained.
Passing by some more of these tattered markers at a constant but unknown speed, you may still be able to gain some information from their placements. For example, since you started counting you have passed exactly M remaining stones; how fast could you have been driving?
입력 형식
- One line containing two positive integers, M and N (2 ≤ M ≤ N ≤ 103): the number of consecutive stones you noticed and the total number of stones along the road respectively.
- One line containing M distinct non-negative integers T1..M in ascending order — the times at which you passed stones in hours (0 ≤ Ti ≤ 1015).
- One line containing N distinct non-negative integers X1..N in ascending order — the distances along the road of each milestone (0 ≤ Xi ≤ 1015) in miles.
출력 형식
Output two lines:
- First, the number of distinct possible speeds at which the car could have been travelling.
- Second, a space-separated list of all of the possible distances between the first milestone you saw and the second milestone you saw, in increasing order.
예제 입력 1
4 12
1 2 4 5
6 8 12 18 26 28 30 34 36 37 39 40
예제 출력 1
2
1 2
예제 입력 2
5 10
1 2 3 4 5
0 1 2 3 4 5 6 7 8 9
예제 출력 2
1
1
예제 입력 3
3 6
1 2 4
11 12 15 19 24 30
예제 출력 3
0
예제 입력 4
2 3
1123456789000 1123456789007
5 8 13
예제 출력 4
2
3 5
Comments