2013年7月30日

hdu 2544 最短路

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2544#include#include#include#includeusing namespace std;const int N =105;const int INF = 0x3f3f3f3f;int map[N][N],dis[N];bool vis[N];int n,m;void init(){ int i , j; memset(map,INF,sizeof(map)); for(i = 1; i cost)map[vi][vj]=map[vj][vi]=cost; }}/*... 阅读全文

posted @ 2013-07-30 11:02 blieveboy 阅读(98) 评论(0) 推荐(0) 编辑

【转】C语言的位运算的优势

摘要: 位运算加速技巧1.如果乘上一个2的倍数数值,可以改用左移运算(Left Shift) 加速 300%x = x * 2;x = x * 64;//改为:x = x > 1;// 2 = 21x = x >> 6;// 64 = 263.数值转整数加速 10%x = int(1.232)//改为:x = 1.232 >> 0;4.交换两个数值(swap),使用 XOR 可以加速20%var t:int = a;a = b;b = t;//equals:a = a^b;b = a^b;a = a^b;5.正负号转换,可以加入 300%i = -i;//改为i = ~i 阅读全文

posted @ 2013-07-30 10:11 blieveboy 阅读(180) 评论(0) 推荐(0) 编辑

导航