HDU 5794 A Simple Chess (lucas定理+费马小定理)
来源:互联网 发布:生成对抗网络发展 编辑:程序博客网 时间:2024/05/22 12:35
A Simple Chess
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2672 Accepted Submission(s): 713
Problem Description
There is a n×m board, a chess want to go to the position
(n,m) from the position (1,1) .
The chess is able to go to position(x2,y2) from the position (x1,y1) , only and if only x1,y1,x2,y2 is satisfied that (x2−x1)2+(y2−y1)2=5, x2>x1, y2>y1 .
Unfortunately, there are some obstacles on the board. And the chess never can stay on the grid where has a obstacle.
I want you to tell me, There are how may ways the chess can achieve its goal.
The chess is able to go to position
Unfortunately, there are some obstacles on the board. And the chess never can stay on the grid where has a obstacle.
I want you to tell me, There are how may ways the chess can achieve its goal.
Input
The input consists of multiple test cases.
For each test case:
The first line is three integers,n,m,r,(1≤n,m≤1018,0≤r≤100) , denoting the height of the board, the weight of the board, and the number of the obstacles on the board.
Then followr lines, each lines have two integers, x,y(1≤x≤n,1≤y≤m) , denoting the position of the obstacles. please note there aren't never a obstacles at position (1,1) .
For each test case:
The first line is three integers,
Then follow
Output
For each test case,output a single line "Case #x: y", where x is the case number, starting from 1. And y is the answer after module 110119 .
Sample Input
1 1 03 3 04 4 12 14 4 13 27 10 21 27 1
Sample Output
Case #1: 1Case #2: 0Case #3: 2Case #4: 1Case #5: 5
Author
UESTC
Source
2016 Multi-University Training Contest 6
题解
不贴代码了,差不多照着打的。
公 式
c(m,n)=m!/((m-n)!*n!)
性质1
C(n,m)= C(n,n-m)
性质2
C(n,m)= C(n-1,m-1)+C(n-1,m)
Lucas(n,m,p)=c(n%p,m%p)*Lucas(n/p,m/p,p)
阅读全文
0 0
- HDU 5794 A Simple Chess (lucas定理+费马小定理)
- hdu 5794 A Simple Chess(Lucas 定理)
- HDU 5794 A Simple Chess (容斥+Lucas定理)
- hdu 5794 A Simple Chess (dp+lucas定理)
- HDU 5794 A Simple Chess (容斥+lucas定理)
- HDU5794-A Simple Chess(Lucas定理)
- HDU 6114 Chess【Lucas定理】
- 【HDOJ 5794】A Simple Chess(大组合数Lucas定理+容斥)
- hdu5794A Simple Chess(lucas定理+dp)
- HDU 5794 A Simple Chess(卢卡斯定理 + 容斥原理)
- hdu 5794 A Simple Chess 【lucas+容斥】
- HDU 5794 A Simple Chess (dp+Lucas组合数取模)
- HDU 5794 A Simple Chess Lucas大数组合数取模
- HDU 3037 lucas + 费马小定理
- hdu 6114 Chess(组合数取模)(Lucas定理)
- hdu 3037 lucas定理
- hdu 4349(Lucas定理)
- HDU 5794 A Simple Chess
- Sublime Text3下配置SublimeLinter进行PHP代码检查
- yum配置
- 微信错误代码45047:客服消息只能发送20条/个用户
- 高效的jQuery代码编写技巧总结
- java基础--1.基础-1.计算机基础
- HDU 5794 A Simple Chess (lucas定理+费马小定理)
- 编写函数实现随机产生指定范围的整数的功能
- 常见镜像源
- 【C++】【LeetCode】53. Maximum Subarray
- * 24种设计模式——原型模式
- mysql数据库
- Android访问网络,使用HttpURLConnection还是HttpClient?
- 51nod 1202 子序列个数 (子序列套路dp)&& HDU 5791 Two (两串求相同子序列)
- 数学建模_国2000A——DNA序列问题中的数据处理