codeforces838D - Airplane Arrangements
太妙啦!
我们把座位摆成一个环,在添加另一个座位,表示坐了这个位置就会有人生气,那么我们现在要求的就是没人坐它的方案数Ans,但是这个并不好求,我们发现对于每个位置,它们的Ans都是一样的,而且Ans的和就是在这n+1个中选位置选方向的所有方案数中的空位置之和。
所以Ans*(n+1)=All*(n+1-m),All=(2(n+1))^m
#include <cstdio>
#define mod 1000000007
using namespace std;
int n,m;
int qp(int a,int b){
int c=;
for(;b;b>>=,a=1ll*a*a%mod)
if(b&)c=1ll*c*a%mod;
return c;
}
int main(){
scanf("%d%d",&n,&m);
printf("%lld\n",1ll*qp(*(n+),m)*(n+-m)%mod*qp(n+,mod-)%mod);
return ;
}
codeforces838D - Airplane Arrangements的更多相关文章
- CF838D Airplane Arrangements
传送门:https://www.luogu.org/problemnew/show/CF838D 这道题反正我自己想是毫无头绪,最后还是听了肖大佬的做法. 因为题中说乘客可以从前后门进来,所以我们可以 ...
- Codeforces.838D.Airplane Arrangements(思路)
题目链接 \(Description\) 飞机上有n个位置.有m个乘客入座,每个人会从前门(1)或后门(n)先走到其票上写的位置.若该位置没人,则在这坐下:若该位置有人,则按原方向向前走直到找到空座坐 ...
- IndiaHacks 2nd Elimination 2017 (unofficial, unrated mirror, ICPC rules)
D. Airplane Arrangements time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- 洛谷 P6672 - [清华集训2016] 你的生命已如风中残烛(组合数学)
洛谷题面传送门 题解里一堆密密麻麻的 Raney 引理--蒟蒻表示看不懂,因此决定写一篇题解提供一个像我这样的蒟蒻能理解的思路,或者说,理解方式. 首先我们考虑什么样的牌堆顺序符合条件.显然,在摸牌任 ...
- Intro to Airplane Physics in Unity 3D – 2017 and 2018
Info:DescriptionHave you ever wanted to build your own Airplane Physics using the Rigidbody componen ...
- Codeforces Round #460 (Div. 2)-C. Seat Arrangements
C. Seat Arrangements time limit per test1 second memory limit per test256 megabytes Problem Descript ...
- Codeforces 919 C. Seat Arrangements
C. Seat Arrangements time limit per test 1 second memory limit per test 256 megabytes input standa ...
- Security arrangements for extended USB protocol stack of a USB host system
Security arrangements for a universal serial bus (USB) protocol stack of a USB host system are provi ...
- codeforces 919C Seat Arrangements 思维模拟
C. Seat Arrangements time limit per test 1 second memory limit per test 256 megabytes input standard ...
随机推荐
- ElasticSearch High Level REST API【7】聚合
获取平均值聚合示例,最大值.最小值.求和类似 public void aggregation(){ RestHighLevelClient client = elasticClient.getRest ...
- spring boot+log4j2快速使用(一)
log4j是Apache的一个开源项目,log4j2和log4j是一个作者,只不过log4j2是重新架构的一款日志组件,他抛弃了之前log4j的不足,以及吸取了优秀的logback的设计重新推出的一款 ...
- JS下载文件常用的方式
下载附件(image,doc,docx, excel,zip,pdf),应该是实际工作中经常遇到一个问题:这里使用过几种方式分享出来仅供参考; 初次写可能存在问题,有问题望指出 主要了解的几个知识 ...
- python--re(匹配字符串)
\d 匹配任何十进制数:它相当于类 [0-9]. \D 匹配任何非数字字符:它相当于类 [^0-9]. \s 匹配任何空白字符:它相当于类 [ fv]. \S 匹配任何非空白字符:它相当于类 [^ f ...
- 【PHP项目】form表单的enctype属性
enctype这个属性管理的是表单的MIME(Multipurpose Internet Mail Extensions)编码,共有三个值可选: 1.application/x-www-form-ur ...
- PHP处理mysql事务
MYSQL的事务处理主要有两种方法.1.用begin,rollback,commit来实现begin 开始一个事务rollback 事务回滚commit 事务确认2.直接用set来改变mysql的自动 ...
- 搭建一个简单的dns缓存服务器
环境:linux 软件:bind97,bind97-utils, bind97-libs ip:192.168.192.130:192.168.192.131 -------------------- ...
- C语言字符篇(一)字符串转换函数
#include <stdlib.h> double atof(const char *nptr); 将字符串转换成双精度浮点数 int atoi(const char *npt ...
- linux c 调用子文件函数
今天在学习初级linux c的时候遇到了如下问题:通过主函数调用同路径下的子文件函数调用失败.博主是这样一一解决的: 首先:hello.c: hello.c: #include<bool.c&g ...
- Linux与BSD不同
https://linux.cn/article-3186-1.html https://www.howtogeek.com/190773/htg-explains-whats-the-differe ...