当前位置: 首页 > 网络知识

[luoguP2886] [USACO07NOV]牛继电器Cow Relays(矩阵)

时间:2026-01-29 09:38:24

传送门

矩阵快速幂,本质是floyd

把 * 改成 + 即可

注意初始化

因为只有100条边,所以可以离散化

#include <cstdio> #include <cstring> #include <algorithm> #define N 101 #define min(x, y) ((x) < (y) ? (x) : (y)) int n, t, s, e, cnt; int x[N], y[N], z[N], a[N]; struct Matrix }; inline Matrix operator * (Matrix x, Matrix y) inline Matrix operator ^ (Matrix x, int y) return ans; } int main() std::sort(a + 1, a + cnt + 1); cnt = std::unique(a + 1, a + cnt + 1) (a + 1); sum.n = sum.m = cnt; for(i = 1; i <= t; i++) sum = sum ^ n; s = std::lower_bound(a + 1, a + cnt + 1, s) a; e = std::lower_bound(a + 1, a + cnt + 1, e) a; printf("%d\n", sum.a[s][e]); return 0; }

  



上一篇:[BZOJ2342] [Shoi2011]双倍回文(manacher)
下一篇:[luoguP2073] 送花(set)
矩阵 DP
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器
  • 英特尔第五代 Xeon CPU 来了:详细信息和行业反应
  • 由于云计算放缓引发扩张担忧,甲骨文股价暴跌
  • Web开发状况报告详细介绍可组合架构的优点
  • 如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳
  • 美光在数据中心需求增长后给出了强有力的预测
  • 2027服务器市场价值将接近1960亿美元
  • 生成式人工智能的下一步是什么?
  • 分享在外部存储上安装Ubuntu的5种方法技巧
  • 全球数据中心发展的关键考虑因素
  • 英特尔与 Vertiv 合作开发液冷 AI 处理器

    英特尔第五代 Xeon CPU 来了:详细信息和行业反应

    由于云计算放缓引发扩张担忧,甲骨文股价暴跌

    Web开发状况报告详细介绍可组合架构的优点

    如何使用 PowerShell 的 Get-Date Cmdlet 创建时间戳

    美光在数据中心需求增长后给出了强有力的预测

    2027服务器市场价值将接近1960亿美元

    生成式人工智能的下一步是什么?

    分享在外部存储上安装Ubuntu的5种方法技巧

    全球数据中心发展的关键考虑因素