codeforces#101194H. Great Cells(数学)
题目链接:
https://codeforces.com/gym/101194
题意:
在$n×m$的各自中填上$1$到$k$的数
定义Greate cell为严格大于同行和同列的格子
定义$A_g$为存在$g$个Greate cell的方案数
求$\sum_{g=0}^{nm}(g+1)*A_g$
数据范围:
$1\leq n \leq 200$
$1\leq m \leq 200$
$1\leq k \leq 200$
分析:
$\sum_{g=0}^{nm}(g+1)*A_g=\sum_{g=0}^{nm}A_g+\sum_{g=0}^{nm}A_g*g$
左边部分为所有排列的方案数也就是$k^{n\times m}$
右边是每个Great cell的贡献
AC代码:
#include<bits/stdc++.h>
#define ll long long
#define pic pair<int,char>
#define pii pair<int,int>
using namespace std;
const int maxn=3e5+7;
const int mod=1e9+7;
ll qpow(ll x,ll y){
ll res=1;
while(y){
if(y&1)res=res*x%mod;
x=x*x%mod;
y/=2;
}
return res;
}
int main(){
// cout<<qpow(2,10)<<endl;
int T;
scanf("%d",&T);
for(int cn=1;cn<=T;cn++){
int n,m,k;
scanf("%d %d %d",&n,&m,&k);
ll ans=qpow(k,n*m),res=0;
for(int i=2;i<=k;i++)
res=(res+qpow(i-1,n+m-2)*qpow(k,(n-1)*(m-1))%mod)%mod;
ans=(ans+res*n*m%mod)%mod;
printf("Case #%d: %lld\n",cn,ans);
}
return 0;
}
codeforces#101194H. Great Cells(数学)的更多相关文章
- Gym - 101194H Great Cells
Problem H. Great Cells 题目链接:https://codeforces.com/gym/101194/attachments Input file: Standard Input ...
- CodeForces 534C Polycarpus' Dice (数学)
题意:第一行给两个数,n 和 A,n 表示有n 个骰子,A表示 n 个骰子掷出的数的和.第二行给出n个数,表示第n个骰子所能掷出的最大的数,这些骰子都有问题, 可能或多或少的掷不出几个数,输出n个骰子 ...
- codeforces 687B - Remainders Game 数学相关(互质中国剩余定理)
题意:给你x%ci=bi(x未知),是否能确定x%k的值(k已知) ——数学相关知识: 首先:我们知道一些事情,对于k,假设有ci%k==0,那么一定能确定x%k的值,比如k=5和ci=20,知道x% ...
- Codeforces Gym 100269G Garage 数学
Garage 题目连接: http://codeforces.com/gym/100269/attachments Description Wow! What a lucky day! Your co ...
- codeforces 701B B. Cells Not Under Attack(水题)
题目链接: B. Cells Not Under Attack 题意: n*n的棋盘,现在放m个棋子,放一个棋子这一行和这一列就不会under attack了,每次放棋子回答有多少点还可能under ...
- codeforces 701 B. Cells Not Under Attack
B. Cells Not Under Attack time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- Codeforces C. Almost Equal (数学规律)
题目链接:http://codeforces.com/contest/1206/problem/C 题解 : 观察可以发现当n为偶数时,1 - 2n是不满足题意的,可以举例n = 2,n = 4试一试 ...
- codeforces 101C C. Vectors(数学)
题目链接: C. Vectors time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Educational Codeforces Round 15 D 数学推公式
D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...
随机推荐
- 获取类的描述信息 DescriptionAttribute
static void Main(string[] args) { var attrs = typeof(TestClass).GetCustomAttributes(typeof(System.Co ...
- AngularJS视图 ng-view
AngularJS支持通过在单个页面上的多个视图的单页应用.要做到这一点AngularJS提供ng-view 和 ng-template指令,以及 $routeProvider 服务. ng-view ...
- 南宁AI项目
1.能了解并对项目整体进度情况有清晰的认识,什么时间点需要完成什么工作项. 2.认识了解项目干系人,能和客户独立沟通交流,理解现场业务,不要一问三不知,什么情况都不了. 3.能推动项目进展和问题及时处 ...
- Go part 2 基础语法
关键字.标识符 标识符: 是用户或系统定义的有意义单词组合,或单词与数字组合(具体意义有定义者决定) 标识符以字母下划线开头,大小写敏感,比如:boy, Boy, _boy, _(匿名变量,用来 ...
- h5获取地理坐标
h5获取地理坐标 方法:h5自带获取地理信息的api api:navigator.geolocation.getCurrentPosition https://developer.mozilla.or ...
- CSS3实现瀑布流布局
讲干货,不啰嗦,瀑布流布局是种常见的布局方式,常用于图片相关的样式展示,通过CSS3的多列(Multi-column)属性,可以简单的实现类似效果. 具体步骤: 1.设置外部容器多列列数(column ...
- 关于WEB前端开发的思考与感悟
万事开头难. 当我想要认真写一篇文章向大家分享我对前端的认识与感悟的时候,突然就深刻的体会到了这句话确实太有道理了. 最近几年对于web前端的传闻很多,比如人才稀缺,简单易学,待遇丰厚,整体势头发展良 ...
- SpringBoot mysql出现The server time zone value '�й���ʱ��' is unrecogni
MySql :8.0.18 引入的mysql驱动: SpringBoot整合Mybatis的框架,在访问Controller的时候 : ava.sql.SQLException: The server ...
- 单元测试自动生成工具evosuite
github地址:https://github.com/EvoSuite/evosuite 官网地址:http://www.evosuite.org 快速开始: 1. junit <de ...
- GVIM、VIM
全世界最好的编辑器VIM之Windows配置篇 Highlight all search pattern matches Top 10 things Vi user need to know abou ...