Shirlies
宁静专注认真的程序媛~
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 21 下一页
摘要: 忠诚的告诉大家:uva上的题目一定要看清楚格式啊,格式错误也是WA啊,~~~~(>_<)~~~~ 因为一个换行符WA了几次。。。Dijkstra的变形。。。求一条路上的最小值然后取多条路中的最大值。。。代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 5 int g[110][110]; 6 int v[110],d[110]; 7 int N,R; 8 int start,end,per; 9 int cas;10 11 bool init()12 { 阅读全文
posted @ 2012-04-17 19:53 Shirlies 阅读(231) 评论(0) 推荐(0) 编辑
摘要: 模板题目了,又一个Krustral变形。。。题意:给你P个点,目前有S个卫星频道(satellite channels),求一条边在连接后中的图中是最大的,但是要求是所用方案中最小的,明显的最小生成树。求最小生成树中最长的那条边就可以了,但是那些最长的边可以卫星通讯(Any two outposts with a satellite channel can communicate via the satellite,其实这里还是有一个疑问的:要是a,b用卫星频道,c,d也用卫星频道,那么如果这两段不用radio是不是也可以通讯啊,根据题意应该是不可以的,如果可以就A不了了),所以求第P-S条最 阅读全文
posted @ 2012-04-16 16:42 Shirlies 阅读(622) 评论(0) 推荐(1) 编辑
摘要: Krustral 变形。。。。。。代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <cmath> 5 6 struct distance 7 { 8 int u,v; 9 double w;10 }d[1000000];11 12 struct point13 {14 int x,y;15 }p[1000];16 17 int f[1000];18 int n;19 int num;20 21 bool cmp(const dista 阅读全文
posted @ 2012-04-16 13:02 Shirlies 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 这一题不错。。。将floyd变了变形。。。代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 5 int point,street,que; 6 int g[1010][1010]; 7 int cas; 8 9 bool init()10 {11 scanf("%d%d%d",&point,&street,&que);12 if(point == 0&&street == 0&&que == 阅读全文
posted @ 2012-04-16 11:16 Shirlies 阅读(225) 评论(0) 推荐(0) 编辑
摘要: Krustral是也。。。View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #include <cmath> 5 6 struct segment 7 { 8 int u,v; 9 double w;10 }s[10000];11 12 struct point13 {14 double x,y;15 }p[110];16 17 int f[105];18 int n;19 int sum;20 double len;21 22 bool cmp 阅读全文
posted @ 2012-04-15 23:30 Shirlies 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 求最短路,Floyd算法,简单的应用不过题目真的很晦涩。。。第一个数x表示与第i个数(通俗一点,第i行,其实也是标号为i的点)相邻的点的个数,然后后面有x个值。代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 5 int g[22][22]; 6 int n; 7 8 bool init() 9 {10 int num;11 for(int i = 1;i <= 20;i ++)12 {13 for(int j = 1;j <= 20;j ++)14 . 阅读全文
posted @ 2012-04-15 21:27 Shirlies 阅读(260) 评论(0) 推荐(0) 编辑
摘要: 这一题做的有点小苦,但是最终取得了成功,(*^__^*) 嘻嘻……起初不知道哪里出问题了,一直WA,然后对照网上的代码一步一步的改啊,提交啊,最终AC了,然后又一步一步的改回到自己原来的样子,(~ o ~)~zZ错误找到了。。。不知道WA了多少次,又AC了多少次,不计算了,而且我的代码运行时间比网上的代码时间更短,成就啊,不过有点小浪费空间,其实两个循环可以合并,就少一点空间了。。。代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 5 int length[60]; 阅读全文
posted @ 2012-04-15 13:06 Shirlies 阅读(323) 评论(0) 推荐(0) 编辑
摘要: 每做一题就对数学更加崇拜!看了别人做的才会做的,细节问题不会处理http://www.mysjtu.com/page/M0/S653/653211.html还是贴上自己的代码吧。。。代码如下: 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 5 int n; 6 7 long long solve() 8 { 9 int m = (int)sqrt(n + 0.5);10 long long sum = 0;11 int count = 0;12 for(int i = 2;i &l 阅读全文
posted @ 2012-04-14 17:40 Shirlies 阅读(189) 评论(0) 推荐(0) 编辑
摘要: uva上面的题目就是不一样啊。。。表扬一下“经典”。。。代码如下: 1 #include <cstdio> 2 #include <cstring> 3 4 int a[100]; 5 int n; 6 void solve() 7 { 8 memset(a,0,sizeof(a)); 9 int len = 0;10 while(n!=0)11 {12 a[len] = (n%2 + 2)%2;//这个取模的方法很有用13 n = (n - a[len ++])/(-2);14 }15 if(len == 0)... 阅读全文
posted @ 2012-04-14 15:20 Shirlies 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 神奇的一题,偶对数学的崇拜加深了!题解:http://www.algorithmist.com/index.php/UVa_106我自己再简单的解释一下吧。。。x2+y2=z2(这些都是在x,y,z互质的情况下推的),可以变成:y2=(z - x) * (z + x),我们再变换一下:(y/2)2 = (z - x)/2 * (z +x )/2 ((z-x)/2和(z + x)/2必然为平方数,因为(z - x)/2和(z + x)/2必然是互质,没有共同的因子,自己可以好好想想,推一推) ,设r2 = (z - x)/2,s2 = (z +x )/2,前面是在互质的情况下退出来的,但是反推的 阅读全文
posted @ 2012-04-14 12:01 Shirlies 阅读(453) 评论(0) 推荐(0) 编辑
上一页 1 ··· 8 9 10 11 12 13 14 15 16 ··· 21 下一页