https://www.luogu.org/problemnew/show/P4452 又一道看题解的费用流. 注意时间也影响节点,像题解那样建边就少很多了. #include<bits/stdc++.h> using namespace std; +; ; const int INF=0x3f3f3f3f; struct Edge{ int to,next,cap,flow,cost; }edge[MAXM]; int head[MAXN],tol; int pre[MAXN],dis[MA…
记得把数组开大一点,不然就RE了... 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define int long long 4 const int N=5e5; 5 const int M=5e5; 6 const int INF=0x3f3f3f3f; 7 8 int n,m,s,t,ans,d[N],maxflow; 9 int tot=1,adj[N],nex[M],to[M],cap[M],cost[M]; 10 bool…
题目大意:给你$m,a,c,X_0,n,g$,求$X_{n+1}=(a\cdot X_n+c) \bmod{m}$,最后输出对$g$取模 题解:矩阵快速幂+龟速乘,这里用了$long\;double$强转 卡点:无 C++ Code: #include <cstdio> #include <cmath> using namespace std; long long m, a, c, x0, n, g; long long mul(long long a, long long b)…