博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 2254(矩阵)
阅读量:6961 次
发布时间:2019-06-27

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

题意:指定v1,v2,要求计算出在t1,t2天内从v1->v2的走法

思路:可以知道由矩阵求,即将其建图A,求矩阵A^t1 + ...... + A^t2.   A^n后,/*A.xmap[v1][v2]即是从v1到v2要n步

所以先预处理出A^1 -A^10000的情况,后面再注意下细节,计算即可.

(每条道路走需要花一天的时间,且不能在某个城市停留,且t1=0时的走法数为0)

开始以为只要t1 = 0就输出0,结果不停WA,一直对照别人的代码- -

结果偶然发现这个特例,它喵的我也是醉了,才发现是题意理解错了,好惨...Orz

 

  1. 特例: 
  2.     Input: 
  3.     1 
  4.     1 1 
  5.     1  
  6.     1 1 0 1 
  7.     Ouput: 
  8.     1 

 

 

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;typedef long long ll;const int mod=2008;const int maxn=5e5;map
has;struct Maxtri{ int xmap[30][30];};int siz;Maxtri mat[10005];Maxtri Mul(Maxtri &a,Maxtri &b){ Maxtri c; for(int i=0; i
t2) swap(t1,t2); int ans=0; for(int i=t1-1; i

  

转载于:https://www.cnblogs.com/Przz/p/5409752.html

你可能感兴趣的文章
Python黑科技:50行代码运用Python+OpenCV实现人脸追踪+详细教程+快速入门+图像识...
查看>>
软件测试质量和效率评价之我见
查看>>
kloxo增加了域名,怎么不能访问?如何重启web服务?
查看>>
国学题库整理
查看>>
jquery chosen 插件 动态设置+更新选项值
查看>>
求最大值及其下标
查看>>
战力会议1
查看>>
水印情缘。。。
查看>>
为什么重写equals一定要重写hashCode?
查看>>
HDU Problem 4006 The kth great number 【队列】
查看>>
win8阉割版中文输入法
查看>>
Codeforces VK Cup 2015 A.And Yet Another Bracket Sequence(后缀数组+平衡树+字符串)
查看>>
以Drools5.5为例说明“规则引擎在业务系统中应用”---起始篇
查看>>
linux清理内存
查看>>
查看硬盘负载情况:iostat命令
查看>>
《人月神话》阅读笔记03
查看>>
Linux下防火墙开启相关端口及查看已开启端口
查看>>
php socket 编程(一)
查看>>
SDUT 简单枚举类型——植物与颜色
查看>>
Windows 下配置Git
查看>>