矩阵快速幂...+快速乘就OK了 -------------------------------------------------------------------------------------- #include<bits/stdc++.h> using namespace std; typedef long long ll; ll MOD, a, c, x, n, g; ll MUL(ll a, ll b) { ll ans = 0; for(; b; b >…
思路:矩阵快速幂搞一搞. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define PLI pair<LL, int> #define ull unsigned long long using namespace std; ; const int inf =…
思路:不能走走过来的路,变点交换跑矩阵快速幂. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define y1 skldjfskldjg #define y2 skldfjsklejg using namespace std; ; ; const int inf = 0x…
实际上,对于位数相同的连续段,可以用矩阵快速幂求出最后的ans,那么题目中一共只有18个连续段. 分段矩阵快速幂即可. #include<cstdio> #include<iostream> #include<cstring> #include<cstdlib> #include<algorithm> #include<queue> #include<cmath> #define ll long long using na…
Description windy在有向图中迷路了. 该有向图有 N 个节点,windy从节点 0 出发,他必须恰好在 T 时刻到达节点 N-1. 现在给出该有向图,你能告诉windy总共有多少种不同的路径吗? 注意:windy不能在某个节点逗留,且通过某有向边的时间严格为给定的时间. Input 第一行包含两个整数,N T. 接下来有 N 行,每行一个长度为 N 的字符串. 第i行第j列为'0'表示从节点i到节点j没有边. 为'1'到'9'表示从节点i到节点j需要耗费的时间. Output 包…
注意到周期234的lcm只有12,也就是以12为周期,可以走的状态是一样的 所以先预处理出这12个状态的转移矩阵,乘起来,然后矩阵快速幂优化转移k/12次,然后剩下的次数暴力转移即可 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int mod=10000; int n,m,s,t,k,x,y,nf,T,w[60]; struct jz { int a[6…
思路: ax+b cx+d 构造矩阵+矩阵快速幂 (需要加各种特判,,,,我好像加少了- ) //By SiriusRen #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define int long long const int mod=1000000007; int n,m,a,b,c,d;char N[1000500],M[1000500]; stru…