The North American Invitational Programming Contest 2018

博客探讨了北美邀请赛2018年的一个编程问题,涉及到字符串的组合、排序和查找位置。给定n个互不相同的初始字符串,通过选择k个字符串进行拼接,生成一系列复合字符串,并按字母顺序排序。要求找到指定测试字符串在排序后的列表中的位置,输出该位置的模10^9 + 7的结果。
摘要由CSDN通过智能技术生成

Consider nn initial strings of lower case letters, where no initial string is a prefix of any other initial string. Now, consider choosing kk of the strings (no string more than once), and concatenating them together. You can make this many such composite strings:

 

\displaystyle n \times (n - 1) \times (n - 2) \times . . . \times (n - k + 1)n×(n−1)×(n−2)×...×(n−k+1)

 

Consider sorting all of the composite strings you can get via this process in alphabetical order. You are given a test composite string, which is guaranteed to belong on this list. Find the position of this test composite string in the alphabetized list of all composite strings, modulo 10^9 + 7109+7. The first composite string in the list is at position 11.

Input Format

Each input will consist of a single test case.

Note that your program may be run multiple times on different inputs.

Each test case will begin with a line with two intege

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值