[POJ 2279] Mr. Young's Picture Permutations
[题目链接]
http://poj.org/problem?id=2279
[算法]
杨氏矩阵与勾长公式
[代码]
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#include <stack>
#include <limits.h>
using namespace std;
#define MAXN 35
typedef long long ll; ll i,j,k,tmp,n,cnt;
ll a[MAXN];
ll num[MAXN*MAXN];
ll x,y; ll gcd(ll x,ll y)
{
return y == ? x : gcd(y,x % y);
} int main()
{ while (scanf("%lld",&n) != EOF && n)
{
cnt = ;
memset(num,,sizeof(num));
for (i = ; i <= n; i++) scanf("%lld",&a[i]);
for (i = ; i <= n; i++)
{
for (j = ; j <= a[i]; j++)
{
cnt++;
for (k = i + ; k <= n; k++)
{
if (a[k] >= j) num[cnt]++;
else break;
}
num[cnt] += a[i] - j + ;
}
}
x = ; y = ;
for (i = ; i <= cnt; i++)
{
x *= i;
y *= num[i];
tmp = gcd(x,y);
x /= tmp;
y /= tmp;
}
printf("%lld\n",x/y);
} return ;
}
[POJ 2279] Mr. Young's Picture Permutations的更多相关文章
- 轮廓线DP:poj 2279 Mr. Young's Picture Permutations
poj 2279 Mr. Young's Picture Permutations \(solution:\) 首先摘取一些关键词:(每行不超过它后面的行)(每排学生安排高度从左到右减少)(学生的高度 ...
- 【杨氏矩阵+勾长公式】POJ 2279 Mr. Young's Picture Permutations
Description Mr. Young wishes to take a picture of his class. The students will stand in rows with ea ...
- POJ P2279 Mr. Young's Picture Permutations 题解
每日一题 day14 打卡 Analysis 五维dpf[a1,a2,a3,a4,a5]表示各排从左端起分别占了a1,a2,a3,a4,a5个人时合影方案数量然后我们枚举a1,a2,a3,a4,a5从 ...
- bzoj 2483: Pku2279 Mr. Young's Picture Permutations -- 钩子公式
2483: Pku2279 Mr. Young's Picture Permutations Time Limit: 1 Sec Memory Limit: 128 MB Description ...
- POJ2279 Mr Young's Picture Permutations
POJ2279 Mr Young's Picture Permutations 描述: 有N个学生合影,站成左对齐的k排,每行分别有N1,N2…NK个人,第一排站最后,第k排站之前.学生身高依次是1… ...
- 【题解】POJ2279 Mr.Young′s Picture Permutations dp
[题解]POJ2279 Mr.Young′s Picture Permutations dp 钦定从小往大放,然后直接dp. \(dp(t1,t2,t3,t4,t5)\)代表每一行多少人,判断边界就能 ...
- Mr. Young's Picture Permutations
Mr. Young's Picture Permutations 给出一个有k列的网格图,以及每列图形的高度\(n_i\),下端对齐,保证高度递减,设有n个网格,询问向其中填1~n保证每行每列单调递增 ...
- poj2279——Mr. Young's Picture Permutations
Description Mr. Young wishes to take a picture of his class. The students will stand in rows with ea ...
- poj2279 Mr. Young's Picture Permutations[勾长公式 or 线性DP]
若干人左对齐站成最多5行,给定每行站多少个,列数从第一排开始往后递减.要求身高从每排从左到右递增(我将题意篡改了便于理解233),每列从前向后递增.每个人身高为1...n(n<=30)中的一个数 ...
随机推荐
- C-字符串和格式化输入\输出
1.字符串是一个或多个字符序列.字符串常量用双引号括起来“abc”,字符常量用单引号括起来‘’. 2.数组是同一类型的数据元素的有序序列.数据元素在内存中是连续存储的. C中没有为字符串定义专门的变量 ...
- Nginx配置Q&A
隐藏响应头 How can remove Nginx from http response header? - Stack Overflow more_set_headers 'Server: my- ...
- Windows 10 常用软件推荐
QQ/TIM 大众的通讯工具,十多年之后的今天,依然是国内常驻用户第一的通讯工具 截图.远程桌面.视频会议.文件传送依旧是非常好用 TIM 算是轻聊版的升级版 微信 for Windows 近年新兴的 ...
- TortoiseSvn问题研究(一)
问题描述 今天在工作中遇到一个SVN方面的问题,牵扯出使用SVN这一段时间的一系列问题. 具体来说,是这样的: 上周五有上线分支,自己的分支需要merge: 很多项目小组都在开发这个项目,再往前好像也 ...
- Algorithms算法题<1.1>
1.1.27 二项分布.估计用一下代码计算binomial(100,50,0.25)将会产生的递归调用次数: public static double binomial(int N,int k,dou ...
- 添加图标:before 和 :after css中用法
#sTitle:after{ position: absolute; top: 2px; font-family: "FontAwesome"; content: "\f ...
- Drop it FreeCodeCamp
function drop(arr, func) { // Drop them elements. for(var start=0 ;start<arr.length; start++){ if ...
- vc++图像保存,重绘
新建mfc应用程序,单文档 增加绘图 分别增加命令响应 添加成员变量UINIT 图形可以运行,如何保存呢?(一个集合类,CPtArt) 用一个类的对象来保存一个图形的三个要素 所以插入一个新的类(通常 ...
- javase 继承练习
package xuexi; 父级 public class Fu { int num=0; public void eat() { System.out.println("父亲在吃饭&qu ...
- redis实现集群加主从复制
a)原理 (1)前提背景:如何解决redis横向扩展的问题----redis集群实现方式 (2)介绍redis 集群 ① Redis 集群是一个提供在多个Redis间节点间共享数据的程序集 ② 优势: ...