博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
bzoj 1297 [SCOI2009]迷路
阅读量:6930 次
发布时间:2019-06-27

本文共 1324 字,大约阅读时间需要 4 分钟。

题目:

用emacs打的第二道题目!

其实很简单。就是拆点。然后就和poj3613一样了。

把边拆成权值个数的点。

#include
#include
#include
#define ll long longusing namespace std;const int N=1015,mod=2009;int n,tot,T;struct Matrix{ int a[N][N]; Matrix(){memset(a,0,sizeof a);} Matrix operator* (const Matrix &b)const { Matrix c; for(int i=0;i<=tot;i++) for(int k=0;k<=tot;k++) for(int j=0;j<=tot;j++) (c.a[i][j]+=(a[i][k]*b.a[k][j]))%=mod; return c; }}r,ans;int main(){ scanf("%d%d",&n,&T);tot=n-1;int x; for(int i=0;i
>=1; } printf("%d\n",ans.a[0][n-1]); return 0;}
View Code

但是WA了。可能是数组太大,爆栈了什么的。

其实应该是把点拆成9个点,自己向自己的第一个点走的距离表示连向自己的边的权值。

#include
#include
#include
using namespace std;const int mod=2009,base=9;int n,tot,T;struct Matrix{ int a[95][95]; Matrix(){memset(a,0,sizeof a);} Matrix operator * (const Matrix &b)const { Matrix c; for(int i=1;i<=tot;i++) for(int k=1;k<=tot;k++) for(int j=1;j<=tot;j++) (c.a[i][j]+=a[i][k]*b.a[k][j])%=mod; return c; }}ans,r;int main(){ scanf("%d%d",&n,&T);int x;tot=n*base; for(int i=0;i
>=1; } printf("%d\n",ans.a[1][(n-1)*base+1]); return 0;}

 

转载于:https://www.cnblogs.com/Narh/p/9254520.html

你可能感兴趣的文章
SQL XQuery的Action
查看>>
SpringMVC中利用@InitBinder来对页面数据进行解析绑定
查看>>
乐视云监控数据存放到influxdb中
查看>>
.NET Core容器化@Docker
查看>>
正则表达式
查看>>
如何独立运行 django脚本(需要settings时)_贪婪的小猪_百度空间
查看>>
jQuery UI dialog插件出错信息:$(this).dialog is not a function
查看>>
WPF中使用DataGridView创建报表控件
查看>>
spring开发_spring环境搭建
查看>>
file_get_contents函数的超时控制(default_socket_timeout)
查看>>
JAVA选项事件
查看>>
Microsoft Team Foundation Server 2010 安装 序列号 注册码
查看>>
RoR网站如何利用lighttpd的X-sendfile功能提升文件下载性能
查看>>
操作XML的类
查看>>
眼高手低,你有这个毛病吗?
查看>>
node.js的request模块
查看>>
asp.net 进度条实现。。
查看>>
【Prism】网络应用脱离浏览器
查看>>
c语言中函数调用惯例
查看>>
[内存管理实践 之 1]在返回按钮中,释放内存
查看>>