摘要: 并查集合并 #include<iostream> using namespace std; const int MAX = 10010; int father[MAX],root[MAX]; int findfather(int x){ if(x==father[x]) return x; else 阅读全文
posted @ 2016-11-25 20:51 demianzhang 阅读(736) 评论(0) 推荐(0) 编辑
摘要: 第一题: 按余数分类,1,2,3分别由哪些基数组成 1—>[1][2+3][3+3+3] 2—>[1+1][2][3+3] 3—>[1+1+1][1+2][3] #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int max... 阅读全文
posted @ 2016-11-24 03:01 demianzhang 阅读(294) 评论(0) 推荐(0) 编辑
摘要: from:piaocoder Common Tangents(两圆之间的公公切线) 题目链接: http://acm.fzu.edu.cn/problem.php?pid=2213 解题思路: 告诉你两个圆的圆心与半径,要你找出他们的公共切线的个数。 套模板即可。 http://blog.csdn.net/piaocoder/article/details/41649089 #include ... 阅读全文
posted @ 2016-11-23 19:01 demianzhang 阅读(204) 评论(0) 推荐(0) 编辑
摘要: refer to: 机器学习公开课笔记(5):神经网络(Neural Network) CS224d笔记3——神经网络 深度学习与自然语言处理(4)_斯坦福cs224d 大作业测验1与解答 CS224d Problem set 1作业 softmax: def softmax(x): assert 阅读全文
posted @ 2016-11-23 00:58 demianzhang 阅读(912) 评论(0) 推荐(0) 编辑
摘要: https://www.patest.cn/contests/pat-a-practise/1022 直接模拟, 输入,按id排序,检索 #include <iostream> #include <string> #include <algorithm> using namespace std; s 阅读全文
posted @ 2016-11-22 18:12 demianzhang 阅读(457) 评论(0) 推荐(0) 编辑
摘要: https://www.patest.cn/contests/pat-a-practise/1030 找最短路,如果有多条找最小消耗的,相当于找两次最短路,可以直接dfs,数据小不会超时。 #include<cstdio> #include<string> #include<cstring> #in 阅读全文
posted @ 2016-11-22 17:31 demianzhang 阅读(342) 评论(0) 推荐(0) 编辑
摘要: https://www.patest.cn/contests/pat-a-practise/1018 先用Dijkstra算出最短路,然后二分答案来验证,顺便求出剩余最小,然后再从终点dfs回去求出路径 #include<cstdio> #include<string> #include<cstri 阅读全文
posted @ 2016-11-22 16:58 demianzhang 阅读(555) 评论(0) 推荐(0) 编辑
摘要: 1.字符串替换ogo+go…换成*** 思路:找ogo记录g位置,做初步替换和标记,非目标字母直接输出, 间隔为2的判断是否一个为标记g,一个为非标记做***替换 #include<iostream> using namespace std; bool mark[110] = { 0 }; int 阅读全文
posted @ 2016-11-21 18:08 demianzhang 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 题意:给定Q(1<=Q<=100000)个数A1,A2…AQ,以及可能多次进行的两个操作 1)对某个区间Ai……Aj的每个数都加n(n可变) 2)对某个区间Ai……Aj的数求和 分析: 树结点只存和,会导致每次加数时都要更新到叶子节点,速度太慢(O(nlog(n))),这是必须避免的 1.在增加时, 阅读全文
posted @ 2016-11-20 16:52 demianzhang 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 此题为入门级线段树 题意:给定Q(1<=Q<=200000)个数A1A2…AQ,多次求任一区间Ai-Aj中最大数和最小数的差 #include<algorithm> #include<cstdio> #include<string> #include<string.h> #include<iostr 阅读全文
posted @ 2016-11-20 13:27 demianzhang 阅读(197) 评论(0) 推荐(0) 编辑