HDU 1003 Max Sum
摘要://简单DP,状态转移方程:dp[i] = max( a[i], a[i]+dp[i-1] )#include <iostream>#include <cstring>#include <cmath>using namespace std;int a[100005];int main(){ int t, n, cnt=0; cin >> t; while (t--) { cin >> n; int i; for (i=0; i<n; i++) cin >> a[i]; //start = ma...
阅读全文
posted @
2013-06-17 19:40
soul214j
阅读(99)
推荐(0)
HDU 1010 Tempter of the Bone
摘要:#include <iostream>#include <cstring>#include <cmath>using namespace std;char map[9][9];int n, m, t, di, dj;int dir[4][2] = {{0,-1}, {0, 1}, {1, 0}, {-1, 0}};//四个方向bool escape;void dfs(int si, int sj, int cnt){ int i, temp; if (si>n || si<=0 || sj>m || sj<=0) //边界 retur
阅读全文
posted @
2013-06-16 20:17
soul214j
阅读(119)
推荐(0)
HDU 2072 单词数
摘要:#include <iostream>#include <set>#include <string>#include <sstream> //使用stringstream需要用到的头文件using namespace std;string str;set<string> article; //set中不会有重复的元素int main(){ while (getline(cin, str) && str != "#") //getline(cin, string)可以接收空格,遇到换行结束 { str
阅读全文
posted @
2013-06-16 15:38
soul214j
阅读(110)
推荐(0)
HDU 2080 夹角有多大
摘要://好吧,水了。。。#include <cstdio>#include <cmath>#define PI 3.1415926using namespace std;//返回值是弧度,需要转换成角度double angle(double x1, double y1, double x2, double y2){ double dtheta,theta1,theta2; theta1 = atan2(y1,x1); theta2 = atan2(y2,x2); dtheta = theta2 - theta1; while (dtheta > PI) ...
阅读全文
posted @
2013-06-16 14:33
soul214j
阅读(132)
推荐(0)