当前位置:网站首页>Question v: hannnnah_ j’s Biological Test
Question v: hannnnah_ j’s Biological Test
2022-07-18 10:54:00 【A little Yu】
Problem Description
hannnnah_j is a teacher in WL High school who teaches biology.
One day, she wants to test m students, thus she arranges n different seats around a round table.
In order to prevent cheating, she thinks that there should be at least k empty seats between every two students.
hannnnah_j is poor at math, and she wants to know the sum of the solutions.So she turns to you for help.Can you help her? The answer maybe large, and you need to mod 1e9+7.Input
First line is an integer T(T≤1000).
The next T lines were given n, m, k, respectively.
0 < m < n < 1e6, 0 < k < 1000Output
For each test case the output is only one integer number ans in a line.
Sample Input
2 4 2 6 5 2 1
Sample Output
0 5
Source
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
long long n,m,p,k;
long long quickpow(long long base,long long power){
long long ret=1;
while(power){
if(power%2)
ret=ret*base%p;
base=base*base%p;
power/=2;
}
return ret;
}
long long C(long long n,long long m){
if(n<m) return 0;
if(m>n-m) m=n-m;
long long a=1,b=1;
for(int i=0;i<m;i++){
a=(a*(n-i))%p;
b=(b*(i+1))%p;
}
return a*quickpow(b,p-2)%p;
}
long long Lucas(long long n,long long m){
if(m==0) return 1;
return Lucas(n/p,m/p)*C(n%p,m%p)%p;
}
int main()
{
p=1e9+7;
int T;
scanf("%d",&T);
while(T--){
scanf("%lld%lld%lld",&n,&m,&k);
if(m==1)
{
printf("%lld\n",n);
}
else
printf("%lld\n",n*Lucas(n-k*m-1,m-1)%p*quickpow(m,p-2)%p);
}
return 0;
}
边栏推荐
- 1. Mx6u system migration-3-uboot startup process
- 问题 V: hannnnah_j’s Biological Test
- 51CTO interview
- 广西二造备考仅剩1天 二级造价师考前三页纸来了 字字提分
- How to judge the quality of an ERP management system
- 集群所有进程查看shell脚本
- 2022-07-15 konghaibo's learning notes of the fifth group
- Basic SQL (I): install MySQL and some simple operations
- Excerpt of new features in PHP version - php7.1x
- 力扣练习——22 买卖股票的最佳时机
猜你喜欢

STL next_permutation() 函数的返回值探析

(手工)【sqli-labs44、45】POST字符型注入、盲注、堆叠注入

The trick of scanning the mobile browser is to know everything and answer questions and translate

ACL访问控制列表案例(7.15)

力扣练习——15 接雨水

2022-07-15 konghaibo's learning notes of the fifth group

Check whether all fields in a piece of data are complete in MySQL

记录一次坑爹内存泄漏排查经历

Kbpc2510w-asemi welding machine special rectifier bridge kbpc2510w
![NC19910 [CQOI2007]矩形RECT](/img/92/49ec3a079a5e8bf61c0bd4bcb669af.gif)
NC19910 [CQOI2007]矩形RECT
随机推荐
【vulnhub】DC9
Experience sharing of packaging AVM components
解决Google colab上安装GPU版本mxnet报错:libnvrtc.so.11.2: cannot open shared object file: No such file...
[paper reading | deep reading] graph neural networks with local structural patterns
SQL storage engine
Zabbix+mysql fpmmm (MPM) monitoring
Excerpt of new features in PHP version - php7.2 X to php7.4 x
Ethernet development and testing, have you done this step right (3)
PHP版本新特性摘选 - PHP7.2.x 到 PHP7.4.x
Check whether all fields in a piece of data are complete in MySQL
How to solve the problem of APP being rejected for collecting personal information?
Advanced process: the independence of programmers to do projects
Nc19910 [cqoi2007] rectangular rect
Paul Holland: predicting the trend of the financial market
正大期货目前开预留4的主账户需要什么条件?信息面
PHP版本新特性摘选 - PHP7.0X
Irezer 5 GT exposure, Lexus same front face, domestic brands began to learn from?
[detailed tutorial] a thorough article on mongodb aggregation query
In strict mode, the method of inserting mysql5.7 into the user table fails to create a new user, so how to modify the strict mode to make him insert successfully. How to change the all permission to s
Talk about throwing eggs in the building again