Algorithm title: UVA 11008 Antimatter Ray clearcutting (memory search + bitwise operation)

Source: Internet
Author: User
Tags bitwise

Problem E

Antimatter Ray clearcutting

Input:standard Input

Output:standard Output

It ' s year 2465, and your are the chief Engineer for Glorified Lumberjacks Inc. on planet. There is a number of trees this you need to cut down and the only weapon you have are a high-powered antimatter ray that W Ill cut through trees like butter. Fuel cells for the antimatter ray are very expensive, so your strategy is:stand somewhere in the forest and shoot the Ray In some chosen direction. This'll cut down all of the trees that lie on the line in that direction. Given the locations of several trees and the number of trees that's are required to cut, what is the minimum number of s Hots that you need to fire?

Input

The "a" of input gives the number of cases, N (at most 20). N test Cases follow. Each one starts with 2 lines containing the integers n (the number of trees in the forest, at most) and M (The number O F trees you need to cut and at most N). The next n lines would each give the (x,y) coordinates of a tree (integers in the range [-1000, 1000]).

Output

For each test case, output the ' line ' case #x: ', where x is the number of the ' test case. On the "Next line", print the number of antimatter ray shots required to cut down at least m trees. Print an empty line between test cases.

Sample input Output for sample input

Notes

In the ' The ' the ' the ' the ' the ' the ' the ' can cut down 4 trees by standing at (0,-1) and firing north (cutting 2 trees) and then Standi Ng at (1,-1) and again firing north (cutting 2 trees).

In the second test case, you are should stand at (3,-1) and fire North (cutting 4 trees) and then stand at ( -1,-1) and Fire n Orth-east (cutting 3 more trees).

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.