上一页 1 2 3 4 5 6 7 8 9 10 ··· 13 下一页
摘要: http://ac.jobdu.com/problem.php?id=1416 1 #include <stdio.h> 2 #include <algorithm> 3 #include <string.h> 4 using namespace std; 5 int n,m; 6 struct Monkey{ 7 char name[101]; 8 int stronger_level; 9 int food_to_eat;10 int need;11 }monkey[10005];12 bool cmp(struct Monkey a,struct Mo 阅读全文
posted @ 2012-03-18 11:06 linyvxiang 阅读(246) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1419 1 #include <stdio.h> 2 #include <string.h> 3 #include <algorithm> 4 using namespace std; 5 struct Record{ 6 char orig_name[201]; 7 char trans_name[201]; 8 }record[201]; 9 void trans(int n)10 {11 int i;12 for(i=0;i<=strlen((record[n].orig_n 阅读全文
posted @ 2012-03-18 11:05 linyvxiang 阅读(243) 评论(0) 推荐(0) 编辑
摘要: 算出位置公式,然后直接模拟就可以,代码写的比较不整齐,好久不写的原因 analysis里面居然给出了打表的方式,USACO不是禁止这样么 1 /* ID:linyvxi1 2 PROB:runround 3 LANG:C++ 4 */ 5 #include <stdio.h> 6 int div_num[33]; 7 bool visited[33]={false}; 8 int len=0; 9 bool trans(int n)10 {11 int j=0;12 int div_cpy[33];13 bool num[10]={false};14 ... 阅读全文
posted @ 2012-03-17 10:15 linyvxiang 阅读(151) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1398静下来分析就行了,不过这题的描述有漏洞,说的是两两交换,没有说必需是相邻的两个才能交换啊还有,注意最大值最小值不唯一的情况 1 #include <stdio.h> 2 int main() 3 { 4 int num[202]; 5 int n; 6 while(scanf("%d",&n)!=EOF){ 7 int i; 8 int max_num=-1; 9 int min_num=500;10 int max_pos=-1... 阅读全文
posted @ 2012-03-08 21:26 linyvxiang 阅读(254) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1399显然是贪心,不过忘了jewellery[i].w,jewellery[i].v中全是整数,做除法要乘以1.0,WA了N次。。看来这东西一旦放下手就不热了。。 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <algorithm> 4 using namespace std; 5 6 struct Jewe{ 7 int v,w; 8 }jewellery[100010]; 9 bool cmp(struct Jewe a, 阅读全文
posted @ 2012-03-08 20:55 linyvxiang 阅读(295) 评论(2) 推荐(0) 编辑
摘要: 在这之前做过九度的题,题目只要求判断能否构成那样的划分,没有让求不同划分的个数,所以dfs就能过,这题dfs到36时超时,各种剪枝都无效。。后来看的题解,原来是DP。。。学习了先贴DP代码,再贴DFS的超时代码 1 /* ID:linyvxi1 2 PROB:subset 3 LANG:C++ 4 */ 5 #include <stdio.h> 6 int main() 7 { 8 freopen("subset.in","r",stdin); 9 freopen("subset.out","w",st 阅读全文
posted @ 2012-03-06 21:34 linyvxiang 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 暴力 1 /* ID:linyvxi1 2 PROB:hamming 3 LANG:C++ 4 */ 5 #include <stdio.h> 6 #include <math.h> 7 #include <stdlib.h> 8 int N,B,D; 9 int max_search_num;10 int final_result[130];11 int num_found;12 13 bool check(int next)14 {15 int s=0;16 for(;s<num_found;s++){17 int temp;18 temp=ne. 阅读全文
posted @ 2012-03-06 20:08 linyvxiang 阅读(132) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1402位运算没的说,不过,如果每道题都考STL,那还有意思么? 1 #include <stdio.h> 2 #include <bitset> 3 using namespace std; 4 5 bitset<1000001> bits; 6 bitset<1000001> bits_assit; 7 int main() 8 { 9 int n;10 while(scanf("%d",&n)!=EOF){11 bits.reset();12 阅读全文
posted @ 2012-02-25 16:50 linyvxiang 阅读(292) 评论(4) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1149 1 #include <iostream> 2 #include <stdio.h> 3 #include <map> 4 #include <string.h> 5 #include <string> 6 using namespace std; 7 8 char str[110]; 9 10 int main()11 {12 int len;13 while(scanf("%s",str)!=EOF){14 map<strin 阅读全文
posted @ 2012-02-25 16:05 linyvxiang 阅读(197) 评论(0) 推荐(0) 编辑
摘要: dfs,好像有人说过其实搜索就是枚举,这下领会到了其实bfs应该更好的吧 1 /* ID:linyvxi1 2 PROB:holstein 3 LANG:C++ 4 */ 5 #include <stdio.h> 6 int v[26]; 7 typedef struct Vit{ 8 int num[26]; 9 }Vit;10 Vit vit[16];11 bool visited[16]={false};12 int final_result[16]={0};13 int V,G;14 int MIN=0x7fffffff;15 int cur_num[26]={0}... 阅读全文
posted @ 2012-02-19 10:56 linyvxiang 阅读(250) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 13 下一页