题目链接:https://code.google.com/codejam/contest/3324486/dashboard#s=p2

题目:

思路:

  

代码实现如下:

 #include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std; typedef long long LL;
typedef pair<LL, LL> pLL;
typedef pair<LL, int> pli;
typedef pair<int, LL> pil;;
typedef pair<int, int> pii;
typedef unsigned long long uLL; #define lson rt<<1
#define rson rt<<1|1
#define lowbit(x) x&(-x)
#define name2str(name) (#name)
#define bug printf("*********\n")
#define debug(x) cout<<#x"=["<<x<<"]" <<endl
#define FIN freopen("D://code//in.txt", "r", stdin)
#define IO ios::sync_with_stdio(false),cin.tie(0) const double eps = 1e-;
const int mod = ;
const int maxn = 2e5 + ;
const double pi = acos(-);
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3fLL; int t, n, m;
LL A[maxn], inv[maxn]; LL Mod_Pow(LL x, int n) {
LL res = ;
while(n) {
if(n & ) res = res * x % mod;
x = x * x % mod;
n >>= ;
}
return res;
} void init() {
A[] = ;
for(int i = ; i < maxn; i++) A[i] = (A[i-] * i) % mod;
inv[maxn-] = Mod_Pow(A[maxn-], mod - );
for(int i = maxn - ; i >= ; i--) {
inv[i] = inv[i+] * (i + ) % mod;
}
} int Com(int n, int m) {
if(n < || m < || m > n) return ;
if(m == || m == n) return ;
return ((A[n] * inv[n-m] % mod) * inv[m]) % mod;
} int main() {
#ifndef ONLINE_JUDGE
FIN;
#endif
init();
int icase = ;
scanf("%d", &t);
while(t--) {
scanf("%d%d", &n, &m);
LL sum = ;
for(int i = ; i <= m; i++) {
if(i % == ) {
sum = (sum + ((Com(m, i) * Mod_Pow(, i) % mod) * A[ * n - i]) % mod) % mod;
} else {
sum = (sum - ((Com(m, i) * Mod_Pow(, i) % mod) * A[ * n - i]) % mod + mod) % mod;
}
}
printf("Case #%d: %lld\n", ++icase, sum % mod);
}
return ;
}

最新文章

  1. CC countari &amp; 分块+FFT
  2. Spark调度管理(读书笔记)
  3. apache2错误日志在哪,可以看到php错误
  4. mongo里面根据对象字段的ID查询 db.Photo.find({&#39;owner.$id&#39;:ObjectId(&#39;xxxx&#39;)}) , 并且使用forEach循环修改查询的数据
  5. Daily Scrum – 1/4
  6. 改变placeholder颜色
  7. poj 2778 DNA Sequence ac自动机+矩阵快速幂
  8. php对象的高级特性
  9. jQuery循环给某个ID赋值
  10. CURL 宏定义列表
  11. img src某个php文件输出图片(回复更改图片readfile读取图片等)
  12. 玩转Web之Json(二)----jquery easy ui + Ajax +Json+SQL实现前后台数据交互
  13. jmeter出现卡死或内存溢出的解决方案
  14. 给hive的metastore做JVM优化
  15. 自动弹出pickerview
  16. 网络拓扑自动发掘之三层设备惯用的SNMP OID的含义
  17. centos7下zabbix安装与部署
  18. JavaWeb学习 (十五)————JSP指令
  19. luogu 4401 矿工配餐 多维dp
  20. c++基础:之封装

热门文章

  1. Littleproxy的使用
  2. python3.6执行AES加密及解密方法
  3. [知乎]老狼:UFS VS NVMe
  4. lepus天兔数据库监控
  5. 【Java并发编程】之一:可重入内置锁
  6. php 关于文件夹的一些封装好的函数
  7. zabbix自定义监控阿里云RDS服务
  8. MT【132】倒序相加因式分解
  9. win7右下角的同步中心怎么去除
  10. 【ZOJ3899】State Reversing 解题报告