Light oj 1005 - Rooks (找规律)
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1005
纸上画一下,找了一下规律,Ank*Cnk.
//#pragma comment(linker, "/STACK:102400000, 102400000")
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
typedef long long LL;
typedef pair <int, int> P;
const int N = 1e5 + ; LL Anm(LL n, LL m) {
LL ans = ;
for(LL i = n; i >= n - m + ; --i) {
ans = ans * i;
}
return ans;
} int main()
{
int t;
LL n, k;
scanf("%d", &t);
for(int ca = ; ca <= t; ++ca) {
scanf("%lld %lld", &n, &k);
printf("Case %d: ", ca);
if(k > n) {
printf("0\n");
continue;
}
LL ans = Anm(n, k);
LL temp = ans;
for(LL i = k; i >= ; --i) {
temp /= i;
}
printf("%lld\n", ans * temp);
}
return ;
}
Light oj 1005 - Rooks (找规律)的更多相关文章
- Light OJ 1005 - Rooks 数学题解
版权声明:本文作者靖心.靖空间地址:http://blog.csdn.net/kenden23/,未经本作者同意不得转载. https://blog.csdn.net/kenden23/article ...
- Light OJ 1005 - Rooks(DP)
题目大意: 给你一个N和K要求确定有多少种放法,使得没有两个车在一条线上. N*N的矩阵, 有K个棋子. 题目分析: 我是用DP来写的,关于子结构的考虑是这样的. 假设第n*n的矩阵放k个棋子那么,这 ...
- 1005 - Rooks(规律)
1005 - Rooks PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB A rook is ...
- (light OJ 1005) Rooks dp
http://www.lightoj.com/volume_showproblem.php?problem=1005 PDF (English) Statistics Forum Tim ...
- Light Oj 1005
题意: 从 n*n 的棋盘中放置 K 个 行和列不冲突的棋子 思路: 组合数学, 先选 k 个 行, k 个列, 就是 C(n,k) ^ 2; 然后 K 个棋子不相同, K ! 全排列 #includ ...
- hdu 1005 Number Sequence(矩阵快速幂,找规律,模版更通用)
题目 第一次做是看了大牛的找规律结果,如下: //显然我看了答案,循环节点是48,但是为什么是48,据说是高手打表出来的 #include<stdio.h> int main() { ], ...
- [Swust OJ 666]--初来乍到(题号都这么溜~~,递归,找规律)
题目链接:http://acm.swust.edu.cn/problem/0666/ Time limit(ms): 1000 Memory limit(kb): 65535 Descriptio ...
- 从HD OJ 1005想到的
杭电OJ [1005](http://acm.hdu.edu.cn/showproblem.php?pid=1005): #####Problem Description > A number ...
- HDU1005 Number Sequence(找规律,周期是变化的)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1005 Number Sequence Time Limit: 2000/1000 MS (Java/O ...
随机推荐
- UVa 10161 Ant on a Chessboard
一道数学水题,找找规律. 首先要判断给的数在第几层,比如说在第n层.然后判断(n * n - n + 1)(其坐标也就是(n,n)) 之间的关系. 还要注意n的奇偶. Problem A.Ant o ...
- Kafka源码中的Producer Record定义
1.ProducerRecord 含义: 发送给Kafka Broker的key/value 值对 2.内部数据结构: -- Topic (名字) -- PartitionID ( 可选) -- Ke ...
- win7下的IP-主机名映射
今天学了个技巧,win7下有个目录:C:\Windows\System32\drivers\etc 该目录下有个文件: hosts 在这个文件里面我们可以映射IP-主机名: 127.0.0.1 loc ...
- ios ble 参考
About Core Bluetooth https://developer.apple.com/library/ios/documentation/NetworkingInternetWeb/Con ...
- 更新Code First生成的数据库
1,首次访问时会自动生成数据库 2,某个Model增加一个字段后,再次访问会报,数据库不是最新 操作 1,Enable-Migrations 注意选择Default project为Star.Core ...
- Yii系列教程(四):使用Memcache保存会话
1环境准备 安装Memcached服务端: yum -y installmemcached.x86_64 安装PHP-Memcache扩展: yum -y installphp-pecl-memcac ...
- php sortable 动态排序
php sortable 动态排序未分页版.php 预览图: <?php mysql_connect("localhost","root","r ...
- Package inputenc Error: Unicode char \u8: not set up for use with LaTeX.
用TexStudio编辑文档时,不知是多加了空格还是啥,总是提示如下错误: Package inputenc Error: Unicode char \u8: not set up for use w ...
- mysql数据库修改密码
更改MySQL用户密码 方法1: 用SET PASSWORD命令 首先登录MySQL. 格式:mysql> set password for 用户名@localhost = password(' ...
- kali2 source
deb http://http.kali.org/kali sana main non-free contrib deb http://security.kali.org/kali-security/ ...