POJ 2279 Mr. Young's Picture Permutations......杨氏矩阵+钩长公式??
来源:互联网 发布:算法第四版答案 pdf 编辑:程序博客网 时间:2024/06/03 02:13
传送门
题目大意:
给出n行,每行有人数限制num[i],并且num[i]>=num[i+1],总人数暂且称为tot=∑num[i],把1~tot这些数字填入矩阵,使得矩阵满足每行单调递增,每列单调递增,求满足要求的矩阵数目
分析:
额,伟大的杨氏矩阵和钩长公式告诉我们此题的解法:>_<
ans=tot!/sum[1]/sum[2]/sum[3]/……../sum[tot]
sum[i]=i号格子右边→_→的格子数+☟下边的格子数
代码如下:
#include<algorithm>#include<iostream>#include<cstring>#include<cstdio>#define int __int64using namespace std;const int maxn=30+5;int num[maxn],sum[maxn*maxn],n,cnt,x,y,tmp;inline int read(void){ char ch=getchar(); int f=1,x=0; while(!(ch>='0'&&ch<='9')){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar(); return f*x;}int gcd(int a,int b){ return a%b==0 ? b : gcd(b,a%b);}signed main(void){ while(n=read()){ for(int i=1;i<=n;i++) num[i]=read(); memset(sum,0,sizeof(sum)),cnt=0,x=1,y=1; for(int i=1;i<=n;i++) for(int j=1;j<=num[i];j++){ cnt++; for(int k=i+1;k<=n;k++){ if(num[k]>=j) sum[cnt]++; else break; } sum[cnt]+=num[i]-j+1; } for(int i=1;i<=cnt;i++) x*=i,y*=sum[i],tmp=gcd(x,y),x/=tmp,y/=tmp; printf("%I64d\n",x/y); } return 0;}
by >o< neighthorn
1 0
- POJ 2279 Mr. Young's Picture Permutations......杨氏矩阵+钩长公式??
- POJ 1825/2279(Young/Mr. Young's Picture Permutations-杨氏矩阵和钩子公式)
- POJ 2279 Mr. Young's Picture Permutations(杨氏矩阵和钩子公式)
- 【POJ2279】【杨氏矩阵/钩子公式】Mr. Young's Picture Permutations
- poj 2779 Mr. Young's Picture Permutations
- 线性DP POJ2279 Mr.Young's Picture Permutations
- poj 2279 杨氏矩阵,钩子公式
- 杨氏矩阵 Young Tableau
- 杨氏矩阵 Young Tableau
- young tableau(杨氏矩阵)
- 杨氏矩阵 Young Tableau
- 杨氏矩阵 Young Tableau
- 杨氏矩阵 Young Tableau
- Young tableau(杨氏矩阵)
- Young氏矩阵
- Young氏矩阵
- young氏矩阵
- Young氏矩阵
- struts.xml配置文件元素的说明
- 【OpenJudge】c语言_计算三角形面积
- 用C语言扩展lua模块(入门)
- CI 分页类的使用
- Android Back键监听
- POJ 2279 Mr. Young's Picture Permutations......杨氏矩阵+钩长公式??
- JAVA设计模式
- 常用排序算法--插入排序解读
- linux系统监控工具——Conky
- sql的四种连接
- 小玩流媒体播放——HLS流媒体点播系统
- 怎样把ppt文档转成pdf文件格式
- USB有时adb shell连不上设备
- 支付解决方案