629. K Inverse Pairs Array

629. K Inverse Pairs Array

大家好,又见面了,我是全栈君。

Given two integers n and k, find how many different arrays consist of numbers from 1 to n such that there are exactly k inverse pairs. 

We define an inverse pair as following: For ith and jth element in the array, if i < j and a[i] > a[j] then it’s an inverse pair; Otherwise, it’s not.

Since the answer may be very large, the answer should be modulo 109 + 7.

Example 1:

Input: n = 3, k = 0
Output: 1
Explanation: 
Only the array [1,2,3] which consists of numbers from 1 to 3 has exactly 0 inverse pair.

 

Example 2:

Input: n = 3, k = 1
Output: 2
Explanation: 
The array [1,3,2] and [2,1,3] have exactly 1 inverse pair.

转载于:https://www.cnblogs.com/jxr041100/p/7947548.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/107863.html原文链接:https://javaforall.cn

【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛

【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...

(0)


相关推荐

  • 10.22 词法分析程序实验心得

    10.22 词法分析程序实验心得

  • vsCode安装使用教程和插件安装

    vsCode安装使用教程和插件安装

  • oracle先排序再分页

    oracle先排序再分页

  • 初识visifire图表「建议收藏」

    初识visifire图表「建议收藏」   在使用过jschart之后,觉得对俺们中国人不是很友善,短时间内是不会支持中文,没法用,也就这样就认识了visifire图表,第一次浏览他的网站就被他的华丽迷上了。   从他的网站上download下来,压缩包里面已经包含了samples。   首先必须在自己的机器上面安装微软的siverlight控件,否则你是不能浏览图表的,这个好办,到微软的网站上下载就可以了。   安装好siv

  • oracle错误代码大全(超详细)

    oracle错误代码大全(超详细)本篇文章是对oracle错误代码进行了详细的总结与分析,需要的朋友参考下ORA-00001:违反唯一约束条件(.)ORA-00017:请求会话以设置跟踪事件ORA-00018:超出最大会话数ORA-00019:超出最大会话许可数ORA-00020:超出最大进程数()ORA-00021:会话附属于其它某些进程;无法转换会话ORA-00022:无效的会话ID;访问被拒绝ORA-00023:会话引用进程私用内存;无法分离会话ORA-00024:单一进程模式下不允许从多个

  • axios安装与基本方法

    axios安装与基本方法安装:1.npm安装:npminstallaxios2.在主入口文件main.js中引用:importaxiosfrom’axios’Vue.use(axios);3.在组件文件中的methods里使用:getNewsList(){this.axios.get(‘api/getNewsList’).then((response)=>{this.newsList=response.data.data;}).cat

发表回复

您的电子邮箱地址不会被公开。

关注全栈程序员社区公众号