上一页 1 ··· 8 9 10 11 12 13 14 15 16 下一页
摘要: 最短路径 dijkstra 1 #include 2 #include 3 #include 4 5 #define MAX INT_MAX 6 #define N 100 7 8 int map[N][N]; 9 int len[N];10 int vis[N];11 int n;12 13 void build() {14 15 int i, j;16 int u, v, c;17 int m; 18 19 scanf("%d", &n);20 memset(map, -1, sizeof(map));21 scanf... 阅读全文
posted @ 2013-08-12 16:59 Levi.duan 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 优先级队列: 1 #include 2 3 int A[100]; 4 int heapsize; 5 6 void swap(int i, int j) { 7 int temp = A[i]; 8 A[i] = A[j]; 9 A[j] = temp;10 }11 12 void huifu(int i){13 int maxheap = i;14 int l = 2*i;15 int r = 2*i + 1;16 if(l A[maxheap])17 maxheap = l;18 if(r A[ma... 阅读全文
posted @ 2013-08-02 21:54 Levi.duan 阅读(335) 评论(0) 推荐(0) 编辑
摘要: 7.29 黄昏时刻(一) 全排列建模: 给了数字n 代表从1-n 个数全排列思路: 1. 输入n,如果n值为‘0’,则退出程序 2. vis[i] 保存 是否对第i个数字进行访问 3. dfs 遍历1-n 个数字的全排列,若重复访问,则越过。直到最终访问结束输出访问的的结果。之后回溯删掉对数字的访问。优化: none代码: 1 #include 2 #include 3 4 int a[20] ,n, vis[20]; 5 6 void dfs(int s) { 7 int i; 8 //如果dfs 次数为n,则输出a数组的内容 9 if(s... 阅读全文
posted @ 2013-07-29 15:57 Levi.duan 阅读(263) 评论(0) 推荐(0) 编辑
摘要: Judge InfoMemory Limit: 65536KBCase Time Limit: 3000MSTime Limit: 3000MSJudger: Number Only JudgerDescriptionWithin Settlers of Catan, the 1995 German game of the year, players attempt to dominate an island by building roads, settlements and cities across its uncharted wilderness.You are employed by 阅读全文
posted @ 2013-07-29 15:09 Levi.duan 阅读(299) 评论(0) 推荐(0) 编辑
摘要: Judge InfoMemory Limit: 32768KBCase Time Limit: 10000MSTime Limit: 10000MSJudger: NormalDescriptionPlease calculate the answer of A+B and the answer of A-B, both A and B are integer.InputThe first line of input contains, the number of test cases. There is only line for each test case. It contains tw 阅读全文
posted @ 2013-07-26 13:22 Levi.duan 阅读(288) 评论(0) 推荐(0) 编辑
摘要: 思想:目的:将中缀表达式(即标准形式的表达式)转换为后缀式。例子:a+b*c+(d*e+f)*g转换成abc*+de*f+g*+转换原则:1.当读到一个操作数时,立即将它放到输出中。操作符则不立即输出,放入栈中。遇到左圆括号也推入栈中。2.如果遇到一个右括号,那么就将栈元素弹出,将符号写出直到遇到一个对应的左括号。但是这个左括号只被弹出,并不输出。3.在读到操作符时,如果此时栈顶操作符优先性大于或等于此操作符,弹出栈顶操作符直到发现优先级更低的元素位置。除了处理)的时候,否则决不从栈中移走"("。操作符中,+-优先级最低,()优先级最高。4.如果读到输入的末尾,将栈元素弹出 阅读全文
posted @ 2013-07-25 19:10 Levi.duan 阅读(267) 评论(0) 推荐(0) 编辑
摘要: 1. 将代码存放到 GitHub , 不然找起来很不方便。2. 集训时,上午看书总结,下午开始刷题。重质不重量。3. 由于SZUOJ 英文晦涩难懂,先从Vijos 开始刷起。4. 每次刷完题后,花10分钟总结一下。不然等于白刷。5. 保持简洁,唯美的风格。6. 每天睡觉前来这里总结一下一天的收获。 阅读全文
posted @ 2013-07-24 18:16 Levi.duan 阅读(179) 评论(4) 推荐(0) 编辑
摘要: dd版本:实战中,未被超越。 1 void quick_sort(int *a,int f,int t) 2 { 3 int i,j,k; 4 i=f; 5 j=t; 6 k=a[f]; 7 8 if(i>=j) return; 9 10 while(i=k)13 j--;14 if(i 2 #define N 250000 3 4 void quick_sort(int *a,int f,int t) 5 { 6 int i,j,k; 7 8 while(f =k)16 ... 阅读全文
posted @ 2013-07-24 17:21 Levi.duan 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 判断素数:第一种方法用于小数据。 1 int k=0; 2 int isprime(int num) 3 { 4 int i, j; 5 j = sqrt(num); 6 for (i = 2; i 2 #include 3 #include 4 5 #define N 100000 6 #define yes '1' 7 #define no '0' 8 char flag[N+1]; 9 10 void is_prime(int n)11 {12 int i, j;13 memset(flag, yes, sizeof(flag)... 阅读全文
posted @ 2013-07-24 16:58 Levi.duan 阅读(203) 评论(0) 推荐(0) 编辑
摘要: Judge InfoMemory Limit: 32768KBCase Time Limit: 5000MSTime Limit: 5000MSJudger: Float Numbers (1e-4) JudgerDescriptionThe chemists are well known because of their weird. Especially when they add water or salt in the same beaker over and over again. Moreover, the still hope you can tell him the mass 阅读全文
posted @ 2013-07-19 00:20 Levi.duan 阅读(268) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 14 15 16 下一页