摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1274一开始solve没有返回位置,然后递归的时候就出错了。。。STL特别好用。。。View Code 1 #include<iostream> 2 #include<string> 3 using namespace std; 4 5 int solve(string &str,string &restr,int pos){ 6 int len=str.length(); 7 while(pos<len){ 8 //是字母 9 if(str[p... 阅读全文
posted @ 2013-02-26 17:05 ihge2k 阅读(363) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1239一道水题,素数筛选即可View Code 1 #include<iostream> 2 #include<cmath> 3 const int N=11000; 4 using namespace std; 5 bool mark[N]; 6 int prime[N]; 7 8 //素数筛选 9 void sieve_prime(){10 memset(mark,true,sizeof(mark));11 mark[0]=mark[1]=false;12 for(i.. 阅读全文
posted @ 2013-02-26 14:58 ihge2k 阅读(347) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1238最主要的是要求字符串的子串,反串,直接用string;View Code 1 #include<iostream> 2 #include<algorithm> 3 #include<string> 4 using namespace std; 5 int n; 6 string s[111]; 7 8 int cmp(const string p,const string q){ 9 return p.length()<q.length();10 }1 阅读全文
posted @ 2013-02-26 11:51 ihge2k 阅读(271) 评论(0) 推荐(0) 编辑