The Review Plan I ZOJ 3687
来源:互联网 发布:三维建筑设计软件apm 编辑:程序博客网 时间:2024/05/21 15:03
The Review Plan I
题意: 你要用n 天复习 n 门课, 每天一门,但是有限制条件,某一天不能复习某几门课。
禁位排列的模板题,看了好长时间别人的博客,看懂了棋子多项式,但是代码看不懂(orz)
棋子多项式与禁位排列:点击打开链接 点击打开链接
定理:
代码:
#include<cstdio>#include<cstring>#include<iostream>#include<cmath>#define MOD 55566677#define N 55using namespace std;typedef long long ll;ll f[N],res;int n,m;int a[N][N];int vis1[N],vis2[N];int ban[N][N];void init(){ f[0]=1; for(int i=1;i<N;i++) f[i]=(f[i-1]*i)%MOD;}void dfs(int k,int num){ if(k>m) { if(num&1) res=((res-f[n-num])%MOD+MOD)%MOD; else res=(res+f[n-num])%MOD; cout<<" res "<<res<<endl; return ; } dfs(k+1,num); if((!vis1[a[k][0]])&&(!vis2[a[k][1]])) { vis1[a[k][0]]=vis2[a[k][1]]=1; dfs(k+1,num+1); vis1[a[k][0]]=vis2[a[k][1]]=0; }}int main(){ init(); int i; while(~scanf("%d%d",&n,&m)) { memset(vis1,0,sizeof vis1); memset(vis2,0,sizeof vis2); memset(ban,0,sizeof ban); for(i=1;i<=m;i++) { scanf("%d%d",&a[i][0],&a[i][1]); if(ban[a[i][0]][a[i][1]]) { i--; m--; } else ban[a[i][0]][a[i][1]]=1; } res=0; dfs(1,0); res=(res%MOD+MOD)%MOD; printf("%lld\n",res); } return 0;}
阅读全文
0 0
- ZOJ 3687 B The Review Plan I
- zoj 3687 The Review Plan I
- The Review Plan I ZOJ 3687
- ZOJ 3687 The Review Plan I 解题报告
- zoj 3687 The Review Plan I(禁为排列模板)
- ZOJ 3687 The Review Plan I(禁位排列)
- zoj-3687-The Review Plan I(禁位排序)
- ZOJ 3687 The Review Plan I(禁位棋盘+dfs)
- ZOJ 3687 The Review Plan I 容斥原理/禁位排列
- ZOJ-3687 The Review Plan I(容斥原理,禁位排列,dfs)
- ZOJ 3687 The Review Plan I 禁位排列 | 容斥原理
- ZOJ 3688 C The Review Plan II
- zoj 3688 The Review Plan II
- zoj 3688 The Review Plan II 组合数学
- zoj 3688 The Review Plan II(禁位排列+容斥原理+乘法逆元)
- zoj 3688 The Review Plan II(容斥原理+禁位排列+逆元)
- ZOJ 1553 Evacuation Plan
- ZOJ Monthly, May 2011 - I The War
- POJ 1625 AC自动机+大数+字符编码
- JPA学习笔记(10)——映射双向一对一关联关系
- CDN详解
- 剑指offer——21.栈的压入、弹出
- swiper animate
- The Review Plan I ZOJ 3687
- error C2440: “=”: 无法从“int [5][5]”转换为“int (*)[4]”
- Http Request Headers各属性的作用
- hdu 6113 度度熊的01世界
- 扩展的放音收号标签
- HYSBZ
- Django 基础教程 视图与网址
- Python爬虫之爬取——限制下载速度
- samba