编程介的小学生 2019-12-23 21:57 采纳率: 20.5%
浏览 51

Cybercrime Donut Investigation 代码的设计

Problem Description
Year 2042. The Internet has evolved to a virtual reality dataspace where crimes are committed every day. The 2041 SWERC winner developed an agent that drops a donut every time a crime is committed in the Cyberspace. Each of the donuts has its own signature. The Madrid Police have a huge database with crimes and their donut signatures.
Today is your day. Your task is to implement a new agent that looks for the records in the database that bear a strong resemblance to the given signature of a dropped donut found at a new crime scene.

Figure 2: The major piece of evidence for today's unsolved crime streak

Experts in virtual criminology have obtained the best similarity measure between donuts: compute the difference in radius of the internal part of the toroids (holes), compute the difference in radius of the external part of the toroids (tubes), and then add up those differences.

Input
The first line of each test case contains n (1<=n<=100,000), the number of donuts in the database. The ith of the following n lines contains the radius of the hole and radius of the tube of the ith donut in the database, described by two integers l and w (1<=l,w<=109). After that there is a line containing q
(1<=q<=50,000), the number of donuts that you are looking for in the database. Then q lines follow, the ith of them describing the dimensions of the newly found ith donut in the same way.
Different test cases are separated by a blank line. A line containing -1 marks the end of the input.

Output
The output of your program on each test case should have q lines, each of them containing an integer. The ith of these lines should contain the similarity between the newly found ith donut and the donut in the
database that most closely resembles it. Outputs for different test cases should be separated by a blank line.

Sample Input
2
2 3
3 4
2
1 1
3 4

2
1 1
9 9
4
4 5
6 5
2 5
3 4

-1

Sample Output
3
0

7
7
5
5

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Python爬取指定微博话题下的内容,保存为txt
    • ¥15 vue2登录调用后端接口如何实现
    • ¥65 永磁型步进电机PID算法
    • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
    • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
    • ¥15 如何处理复杂数据表格的除法运算
    • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
    • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
    • ¥15 latex怎么处理论文引理引用参考文献
    • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?