BZOJ 1172 Balkan2007 Dream
来源:互联网 发布:平面设计制图软件 编辑:程序博客网 时间:2024/06/05 10:18
提示:
1. 一个乘积如果要判断整除
2. 每一行最多取两个可以单独抽出来做
#include <algorithm>#include <iostream>#include <cstdlib>#include <cstring>#include <cassert>#include <cstdio>#include <vector>#include <cmath>#include <queue>#include <map>using namespace std;const int maxn = 210;int n , m , k , l , cnt;int d[maxn][maxn] , t[maxn] , now[maxn] , g[maxn][11000];map<int , int> dic; int redic[maxn] , trans[maxn][maxn];int main(int argc, char *argv[]) { cin>>n>>m>>k>>l; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%d" , g[i] + j); for(int i=1;i<=k;i++) if(k % i == 0) redic[++cnt] = i , dic[i] = cnt; for(int i=1;i<=cnt;i++) for(int j=1;j<=cnt;j++) trans[i][j] = dic[__gcd((int)((1LL*redic[i]*redic[j])%k) , k)]; d[0][1] = 1; for(int i=1;i<=n;i++) { memset(t , 0 , sizeof t); for(int j=1;j<=m;j++) t[dic[__gcd(g[i][j] , k)]]++; memcpy(now , t , sizeof t); if(1 < i && i < n) { for(int j=1;j<=cnt;j++) for(int k=1;k<=cnt;k++) (now[trans[j][k]] += t[j]*t[k]) %= l; for(int j=1;j<=cnt;j++) (now[trans[j][j]] -= t[j]) %= l; } for(int j=1;j<=cnt;j++) for(int k=1;k<=cnt;k++) (d[i][trans[j][k]] += d[i-1][j]*now[k]) %= l; } cout<<(d[n][cnt]+l)%l<<endl; return 0;}
那么我们就可以把相同
1 0
- BZOJ 1172 Balkan2007 Dream
- 【BZOJ 1176】 [Balkan2007]Mokia
- bzoj 1176: [Balkan2007]Mokia
- BZOJ 1176 [Balkan2007] Mokia
- bzoj 1176: [Balkan2007]Mokia
- BZOJ P1174[Balkan2007]Toponyms
- BZOJ 1174: [Balkan2007]Toponyms
- bzoj 1176 [Balkan2007]Mokia
- bzoj 1176: [Balkan2007]Mokia
- 【分治】 BZOJ 1176 [Balkan2007]Mokia
- BZOJ 1170 [Balkan2007]Cipher Hash
- BZOJ 1176: [Balkan2007]Mokia CDQ
- BZOJ 1176 [Balkan2007]Mokia CDQ分治
- BZOJ 1176: [Balkan2007]Mokia CDQ分治
- bzoj 1176: [Balkan2007]Mokia 【CDQ分治】
- bzoj 1176: [Balkan2007]Mokia(cdq分治)
- 【BZOJ 1176】 [Balkan2007]Mokia cdq分治
- BZOJ 1176: [Balkan2007]Mokia (CDQ分治)
- Highstock+flask+mysql实现多线条动态刷新
- 各种颜色的RGB值
- 测试下kafka是否能成功运行
- 解决VM下Linux中mysql无法远程连接的问题,报错码1130,1045
- 用DMA直接驱动GPIO,实现GPIO最高输出速率
- BZOJ 1172 Balkan2007 Dream
- 源码分析 --- Context
- linphone函数video_stream_event_cb()分析
- 【项目中---WebView】Webview打开本地图片文件选择解决方案
- Relation Extraction中SVM分类样例unbalance data问题解决 -松弛变量与惩罚因子
- poj 3264
- linphone函数ms_filter_link分析
- android The specified child already has a parent. You must call removeView() on the child's parent f
- 统计数组中出现次数最多的元素并输出