编程介的小学生 2019-09-02 10:33 采纳率: 20.5%
浏览 171

环球旅行的问题,Travel around the world

Problem Description
Around the World in 80 Days is a 2004 comedy film based on Jules Verne's novel of the same name. It stars Jackie Chan, Steve Coogan and Cécile de France. The film is set in 19th-century Britain and centers on Phileas Fogg, here reimagined as an eccentric inventor and his efforts to circumnavigate the globe in 80 days. During the trip, he is accompanied by his Chinese valet, Passepartout.

Robust is attracted by the film and planning for a tour around the world.

There are N countries in the world,and Robust has assigned each country a value Fi for friendliness to tourist.

Robust may go from country A to country B if the differences |Fa-Fb| is not bigger than M(FDL,Friendliness Difference Limit),or he would feel uncomfortable.
Robust wishes to go to each country for exactly one time.
Now he is choosing a country A to begin and a country B to end his tour(A!=B),
he wonders how many different choices he could make, ie ,how many different pairs of (A,B) that would satify Robust’s needs.

Input
Input contains multiple cases.
Each test case starts with two integer N(2<=N<=10^4) ,M(1<=M<=10^6), indicating that there are N countries and the FDL. Follow by one lines contains N integers , the ith integer Fi(0<=Fi<=10^6) represents country i’s friendliness to tourist.

Output
For each test case, output the different choices that Robust could make to choose a country to begin and a country to end his tour.

Sample Input
2 2
1 2
3 1
4 5 6

Sample Output
2
2

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 求差集那个函数有问题,有无佬可以解决
    • ¥15 【提问】基于Invest的水源涵养
    • ¥20 微信网友居然可以通过vx号找到我绑的手机号
    • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
    • ¥15 解riccati方程组
    • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
    • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
    • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
    • ¥50 树莓派安卓APK系统签名
    • ¥65 汇编语言除法溢出问题