IndiaHacks 2nd Elimination 2017 (unofficial, unrated mirror, ICPC rules)
2 seconds
256 megabytes
standard input
standard output
There is an airplane which has n rows from front to back. There will be m people boarding this airplane.
This airplane has an entrance at the very front and very back of the plane.
Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then board the plane one by one starting with person 1. Each person can independently choose either the front entrance or back entrance to enter the plane.
When a person walks into the plane, they will walk directly to their assigned seat. Then, while the seat they’re looking at is occupied, they will keep moving one space in the same direction. A passenger will get angry if they reach the end of the row without finding their assigned seat.
Find the number of ways to assign tickets to the passengers and board the plane without anyone getting angry. Two ways are different if there exists a passenger who chose a different entrance in both ways, or the assigned seat is different. Print this count modulo 109 + 7.
The first line of input will contain two integers n, m (1 ≤ m ≤ n ≤ 1 000 000), the number of seats, and the number of passengers, respectively.
Print a single number, the number of ways, modulo 109 + 7.
3 3
128
Here, we will denote a passenger by which seat they were assigned, and which side they came from (either "F" or "B" for front or back, respectively).
For example, one valid way is 3B, 3B, 3B (i.e. all passengers were assigned seat 3 and came from the back entrance). Another valid way would be 2F, 1B, 3F.
One invalid way would be 2B, 2B, 2B, since the third passenger would get to the front without finding a seat.
一群人要登机,飞机有前后两个门,可以任意选择一门登机。n个座位m排问有多少种登机方法
只考虑从1个门登机,那么总数就要乘上2^m,因为每个人都有2种选择,接下来考虑座位的问题,看样子好像是一个人有座位了就必须向下移,如果把这些人按照座位排队的话(只考虑先后),那么我就应该乘上(n-m+1),其实只要确定第一个人,每个人都有n+1种排队的选择
综上 (n+1)^(m-1)*(n-m+1)*2^m
#include<stdio.h>
const int mod=1e9+;
int po(int x,int k)
{
int sum=;
while(k)
{
if(k&)
{
sum=1LL*sum*x%mod;
}
x=1LL*x*x%mod;
k>>=;
}
return sum;
}
int main()
{
int n,m;
scanf("%d%d",&n,&m);
printf("%d\n",1LL*po(n+,m-)*(n-m+)%mod*po (,m)%mod);
return ;
}
IndiaHacks 2nd Elimination 2017 (unofficial, unrated mirror, ICPC rules)的更多相关文章
- 2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred)
2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred) easy: ACE ...
- CF_2018-2019 Russia Open High School Programming Contest (Unrated, Online Mirror, ICPC Rules, Teams Preferred)
只做了两个就去上课去啦... A. Company Merging time limit per test 1 second memory limit per test 512 megabytes i ...
- 2018-2019 ICPC, NEERC, Northern Eurasia Finals (Unrated, Online Mirror, ICPC Rules, Teams Preferred) Solution
A. Alice the Fan Solved. 题意: 两个人打网球,要求teamA 的得分与其他队伍拉开尽量大 输出合法的方案 思路: $dp[i][j][k][l] 表示 A 赢i局,其他队伍赢 ...
- 2018-2019 Russia Open High School Programming Contest (Unrated, Online Mirror, ICPC Rules, Teams Preferred)
前言 有一场下午的cf,很滋磁啊,然后又和dalao(见右面链接)组队打了,dalao直接带飞我啊. 这是一篇题解,也是一篇总结,当然,让我把所有的题目都写个题解是不可能的了. 按照开题顺序讲吧. 在 ...
- 2019-2020 ICPC, NERC, Northern Eurasia Finals (Unrated, Online Mirror, ICPC Rules, Teams Preferred)
这是一场三人组队赛来的,单人带电子模板不限时单挑试一下.按照难度排序. B - Balls of Buma 题意:玩祖玛,射入任意颜色的球一个,当某段长度变长了且长度变长后>=3则这段就会消除, ...
- 2021-2022 ICPC, NERC, Northern Eurasia Onsite (Unrated, Online Mirror, ICPC Rules, Teams Preferred) J. Job Lookup
题意 n个节点,n<=200,你需要构造这n个几点成为一棵树,并且这棵树的中序遍历为1-n; 你构造树的节点之间的最短路构成一个n×n的最短距离矩阵d: 同时给你n×n的权重矩阵c:最最小的Σd ...
- 2019-2020 ICPC, NERC, Southern and Volga Russian Regional Contest (Online Mirror, ICPC Rules, Teams Preferred)【A题 类型好题】
A. Berstagram Polycarp recently signed up to a new social network Berstagram. He immediately publish ...
- 2020-2021 ICPC, NERC, Southern and Volga Russian Regional Contest (Online Mirror, ICPC Rules) D. Firecrackers (贪心,二分)
题意:有个长度为\(n\)的监狱,犯人在位置\(a\),cop在位置\(b\),你每次可以向左或者向右移动一个单位,或者选择不动并在原地放一个爆竹\(i\),爆竹\(i\)在\(s[i]\)秒后爆炸, ...
- 2020-2021 ICPC, NERC, Southern and Volga Russian Regional Contest (Online Mirror, ICPC Rules) C. Berpizza (STL)
题意:酒吧里有两个服务员,每个人每次都只能服务一名客人,服务员2按照客人进酒吧的顺序服务,服务员3按照客人的钱来服务,询问\(q\),\(1\)表示有客人进入酒吧,带着\(m\)块钱,\(2\)表示询 ...
随机推荐
- cf1028C. Rectangles(前缀和)
题意 给出$n$个矩形,找出一个点,使得至少在$n$个矩阵内 Sol 呵呵哒,昨天cf半夜场,一道全场切的题,我没做出来..不想找什么理由,不会做就是不会做.. 一个很显然的性质,如果存在一个点 / ...
- maven 3.3.9版本下载地址
请使用迅雷下载 http://www-us.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.zip
- C# 操作字符串,在某些特定的字符后面或前面添加其它字符
C# 操作字符串,在某些特定的字符后面或前面添加其它字符,解决方法: 字符串替换或正则表达式替换即可. 示例:实现的是在每个“第”前面添加一个逗号,在每个“方案”后面添加一个冒号. string s ...
- 你不知道的HTTP之首部字段一览
一.HTTP/1.1 首部字段一览 HTTP 首部字段根据实际用途被分为以下 4 种类型: 1.通用首部字段:请求报文和响应报文两方都会使用的首部. 首部字段名 说明 Cache-Control 控制 ...
- decompressedResponseImageOfSize:completionHandler:]_block_invoke
原因: It turns out the linker error was caused by the CGImageSourceCreateWithData call. And the root ...
- CSS的相对定位和绝对定位
relative的意思就是相对自己的一开始的位置进行的定位.如图: 但是这个元素的本身边距不变,还在原来位置 absolute的意思就是 如果它的父元素设置了除static之外的定位,比如pos ...
- vector的基本用法
#include<iostream> #include<vector> #include<algorithm> using namespace std; int m ...
- 火狐浏览器返回不加载JS
火狐浏览器 go(-1),返回后不加载JS,谷歌会加载. 总结: Firefox和Safari在back时不会触发load, ready事件! 解决方法: $(window).unload(funct ...
- perl 引用(数组和hash引用) --- perlreftut - Mark 的一个简单的'引用'教程 ---Understand References Today. --Mark Jason Dominus, Plover Systems (mjd-perl-ref+@plover.com)
https://blog.csdn.net/fangwei1235/article/details/8570886 首页 博客 学院 下载 论坛 APP 问答 商城 活动 VIP会员 招聘 ITeye ...
- C#在透明窗体WinForm上面画图(电子尺小工具的实现)
前几天要做一个微信调一调的外挂,里面用到了尺子测量距离,然后就自己下载了一个电子尺,最近要升级我的跳一跳外挂,然后就准备自己做一个电子尺,嵌入到我的外挂里面,在嵌入到我的外挂之前,我自己做了一个完整版 ...