上一页 1 ··· 7 8 9 10 11 12 13 下一页

2013年8月12日

POJ1845-Sumdiv大数约数和

摘要: POJ1845-Sumdiv大数约数和 阅读全文

posted @ 2013-08-12 16:24 GyyZyp 阅读(1363) 评论(0) 推荐(0) 编辑

poj1159 Palindrome 区间DP

摘要: 题目链接:http://poj.org/problem?id=1159思路1:区间DP思想:定义dp[i][j]表示从区间(i,j)之间需要增加的字符的最少数量,那么如果s[i]==s[j],那么dp[i][j]=dp[i-1][j-1]否则dp[i][j]=min(dp[i+1][j]+1,dp[i][j-1]+1);如果直接DP,需要开5001*5001的数组,用int会超内存用short int 能过;代码如下: 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 short in 阅读全文

posted @ 2013-08-12 13:21 GyyZyp 阅读(209) 评论(0) 推荐(0) 编辑

poj 2955 Brackets 区间DP

摘要: 题目链接:http://poj.org/problem?id=2955不容易啊,终于把这道题A了,还是对区间DP不熟悉啊。。思路:关键就是怎样进行状态转移;我的想法是定义dp[i][j]表示从i到j的最优匹配数,那么对于k(i 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 int dp[110][110]; 8 string s; 9 bool match(int i,int j)10 {11 if((s[i]=='('&&s[j]==')')||(s[i 阅读全文

posted @ 2013-08-12 11:19 GyyZyp 阅读(154) 评论(0) 推荐(0) 编辑

2013年8月11日

POJ2635-The Embarrassed Cryptographer 大数求余

摘要: POJ2635-The Embarrassed Cryptographer 大数求余 阅读全文

posted @ 2013-08-11 17:17 GyyZyp 阅读(157) 评论(0) 推荐(0) 编辑

2013年8月10日

hdu 2114 Calculate S(n) 数论(简单题)

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2114自己对数论一窍不通啊现在,做了一道水题,贴出来吧。。。主要是让自己记住这个公式:前n项和的立方公式为 : s(n)=(n*(n+1)/2)^2;前n项和的平方公式为:s(n)=n*(n+1)(2*n+1)/6;代码: 1 #include 2 #include 3 #include 4 using namespace std; 5 int main() 6 { 7 long long int ans; 8 long long int n; 9 ... 阅读全文

posted @ 2013-08-10 23:39 GyyZyp 阅读(313) 评论(0) 推荐(0) 编辑

hdu2059 龟兔赛跑 DP

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2059虽然 知道是DP ,刚开始一直没有想出状态转移方程。刚开始的思路就是定义dp[i]表示到达第i个加油站的最优时间,但是却一直在想其与在第i-1的加油站加油和不加油之间的转移关系后来看别人的思路,觉得自己又弱了,应该是考虑和前面的所有加油站的关系对于每一个站点i, 我们可以假设在j (0 2 #include 3 #include 4 #include 5 using namespace std; 6 double d[110]; 7 double dp[110]; 8 void init() 阅读全文

posted @ 2013-08-10 18:44 GyyZyp 阅读(251) 评论(0) 推荐(0) 编辑

2013年8月9日

hdu2612 Find a way BFS

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2612思路:裸的BFS,对于Y,M分别进行BFS,求出其分别到达各个点的最小时间;然后对于@的点,将两者的最小时间相加即为到达此点的总时间,遍历所有@点,更新结果即可;代码: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #define MAX 0x7f7f7f7f 7 using namespace std; 8 int n,m; 9 int startY_x,startY_y; 10 int startM_x... 阅读全文

posted @ 2013-08-09 19:56 GyyZyp 阅读(171) 评论(0) 推荐(0) 编辑

POJ1012-Joseph数学

摘要: POJ1012-Joseph数学 阅读全文

posted @ 2013-08-09 18:06 GyyZyp 阅读(226) 评论(0) 推荐(0) 编辑

hdu 题目分类

摘要: 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201 1202 1205 1209 1212(大数取模) 1216(链表)1218 1219 1225 1228 阅读全文

posted @ 2013-08-09 16:51 GyyZyp 阅读(143) 评论(0) 推荐(0) 编辑

hdu2717Catch That Cow 简单BFS

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2717刚开始思路错了,用的DP,一直WA,后来才发现是搜索,还是简单的BFS,顿时。。。。思路:BFS 三个方向即可;代码: 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define MAX 100010 9 using namespace std;10 int n,k;11 int cur,next;12 int step[MAX];13 queueq;14 void bfs()1. 阅读全文

posted @ 2013-08-09 16:04 GyyZyp 阅读(397) 评论(0) 推荐(0) 编辑

上一页 1 ··· 7 8 9 10 11 12 13 下一页

导航