上一页 1 ··· 10 11 12 13 14
摘要: //多个起点,要最短得目标,不妨倒过来从目标出发,去找最近的点更新!!!!!!递归时思路要清楚#include#includeusing namespace std;int a[202][202]; int ax,ay;int f[4][2]={0,1,1,0,-1,0,0,-1};int mmin... 阅读全文
posted @ 2013-11-11 16:10 天羽屠龙舞 阅读(144) 评论(0) 推荐(0)
摘要: #include#includeusing namespace std;int a[105][105]; int d[8][2]={0,1,0,-1,1,0,-1,0,-1,-1,-1,1,1,-1,1,1}; //八个方向!方向向量。void dfs(int x,int y){... 阅读全文
posted @ 2013-11-03 16:06 天羽屠龙舞 阅读(112) 评论(0) 推荐(0)
摘要: 开始用dijkstra直接求,发现不行,算法问题(1-2,(30),2-4(20),1--3(10),3--4(100)最后一个点无法更新,导致错误),后用取负,加大数法也没过。现在(寒假了):求负权的(无负环),或者最长路(一样,取负求最短),不可以dijkstra,用 spfa可以#includ... 阅读全文
posted @ 2013-10-04 15:37 天羽屠龙舞 阅读(170) 评论(0) 推荐(0)
摘要: 算法是关键,得出1-m内的互质数,然后类推计算即可。下面有详细说明。#include#includeusing namespace std;int a[1000001];int p[1000000]; //用a来筛去m的唯一分解后的质因子及其倍数。int main(){ int m,k; while... 阅读全文
posted @ 2013-08-20 11:10 天羽屠龙舞 阅读(154) 评论(0) 推荐(0)
摘要: 本次,学到了反素数相关知识,也更深地了解了DFS递归搜索。以不同素数来进行分层搜索,指数用来每层可以选择的。#includeusing namespace std;long long prime[15]={2,3,5,7,11,13,17,19,23,29,31,37,39,41,43};long ... 阅读全文
posted @ 2013-08-19 14:41 天羽屠龙舞 阅读(104) 评论(0) 推荐(0)
上一页 1 ··· 10 11 12 13 14