编程介的小学生 2019-03-28 23:23 采纳率: 20.5%
浏览 232

因数的合并,真分数化简的一个算法,怎么利用的C语言的程序技术来实现代码的

Problem Description

During the Trade Federation invasion of Naboo, Anakin Skywalker won the Boonta Eve Classic on Tatooine, securing his freedom from a life of slavery. Betting on the races was a popular pastime with many of the watchers on Tatooine and it was through Qui-Gon Jinn's bet with Watto that Skywalker would win the race that Skywalker was freed.

— Wookieepedia

Here comes the most awesome racing in the universe! Little Anakin sits in his own podracer, breathing deeply. He must win.

The real podracing is deadly. In this circular track (again L in length), participants start in distinct locations and race with distinct speeds (the speed can be positive and minus, which means running clockwise and counterclockwise). Every podracer is equipped with a powerful weapon system respectively -- all for triumphing over enemies!!! yes! enemies!

If two competitors meet, which means that they reach an identical location simultaneously, the one with less powerful weapon system will be destroyed and be knocked out of the racing -- dead or alive. The power of the i-th participant is exactly i, and because each person runs with a distinct speed, so there must be a winner.

The racing stops when there is only one person still running in the track -- our winner! The others are crushed into pieces.

Little Anakin wants to know, when the racing will stop.

Input
The first line contains an integer T (T≤1000), denoting the number of test cases.

For each test case, the first line contains two integers n (2≤n≤105) and L (1≤L≤109).

The following line contains n distinct integers d1,d2,...,dn (0≤di<L), representing the starting points of the participants.

The next line contains n distinct integers v1,v2,...,vn (0≤|vi|≤109), representing the velocity of the participants.

The sum of all n in all test cases doesn't exceed 2×106.

Output
One line for each test case. You should output the answer that is reduced to lowest terms.

Sample Input
2
2 4
0 2
3 2
10 100
56 89 62 71 7 24 83 1 47 52
9 -16 34 -38 47 49 -32 17 39 -9

Sample Output
2/1
37/7

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
    • ¥50 成都蓉城足球俱乐部小程序抢票
    • ¥15 yolov7训练自己的数据集
    • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
    • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
    • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
    • ¥20 matlab yalmip kkt 双层优化问题