
ACM
Rain722
这个作者很懒,什么都没留下…
展开
-
HDU1532Drainage Ditches(网络流Ford-Fulkerson模板)
网络流Ford-Fulkerson模板代码: #include #include #include #include using namespace std; const int N = 250; const int INF = 0x3f3f3f3f; struct Node { int to; int cap; int rev; }; vector v[N]; b原创 2016-11-25 16:52:26 · 443 阅读 · 0 评论 -
ACM读写挂
测了下读取5*10^6规模数据的时间 cin要8500ms, cin关同步流后也要2600ms, scanf要860ms, 读写挂只要170ms, 读写挂对于卡常数的题还是非常有优势的 #include //打表代码 using namespace std; int main(){ freopen("1.out", "w", stdout); for(int i = 1; i 500原创 2016-09-09 12:37:43 · 1439 阅读 · 0 评论 -
Dijkstra与spfa模板
Dijkstra优先队列优化: #include #include #include #include #include using namespace std; const int INF = 0x3f3f3f3f; const int maxn = ; int head[maxn], dis[maxn], cnt, n, m; struct edge { int v, w, next原创 2016-11-25 16:54:37 · 621 阅读 · 0 评论 -
kruskal模板
时间复杂度: E为图中的边数 算法思想:从权值最小的边开始,如果这条边连接的两个节点于图G中不在同一个连通分量中,则添加这条边到图G中 #include #include #include using namespace std; const int maxe = 4000; const int maxn = 55; struct Edge { int u, v, w; }edge[m原创 2017-03-24 19:59:10 · 386 阅读 · 0 评论 -
prim模板
邻接矩阵模板:时间复杂度O(V2) #include #include #include using namespace std; const int maxn = 55; const int inf = 0x3f3f3f3f; int road[maxn][maxn], dis[maxn];//dis[i]表示到点i的权值最小的边 bool vis[maxn]; int n; void pri原创 2017-03-24 18:09:35 · 420 阅读 · 0 评论 -
等比数列二分求和(首项为0次项与1次项的方法)
首项为1次项的,前面的博客中已经有过讲解:http://blog.youkuaiyun.com/rain722/article/details/71034438 附上代码: #include #include #include using namespace std; const int M = 1000000007; typedef long long LL; LL power(LL a,LL原创 2017-05-02 15:19:14 · 1224 阅读 · 0 评论 -
超级读写挂
#define FI(n) FastIO::read(n) namespace FastIO { const int SIZE = 1 << 16; char buf[SIZE], obuf[SIZE], str[60]; int bi = SIZE, bn = SIZE, opt; int read(char *s) { while (bn) { for (; bi < bn原创 2017-10-18 20:07:54 · 347 阅读 · 0 评论 -
Java大数类排序
import java.lang.reflect.Array; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { Scanner cin=new Scanner(原创 2017-10-16 14:41:04 · 1227 阅读 · 0 评论 -
poj3070Fibonacci(矩阵快速幂模板)
代码一: #include #include using namespace std; const int MOD = 10000; int fast_mod(int n) { int base[2][2] = {1, 1, 1, 0}; int ans[2][2] = {1, 0, 0, 1}; int tmp[2][2]; while(n) {原创 2016-11-03 15:24:19 · 386 阅读 · 0 评论