
poj
文章平均质量分 59
devYzhou
Be a man,do the right thing
展开
-
poj-1012 Joseph
http://poj.org/problem?id=1012记得这事刚学数据结构链表的经典题目水过题数吧~#include#include using namespace std;int J[14];int k;void init(){ for(int k=1; k<14; k++) { int n=2*k; int ans[原创 2013-08-19 00:17:39 · 731 阅读 · 0 评论 -
poj-2777 线段树lazy标记+位运算
题目来源:http://poj.org/problem?id=2777题目意思很好懂 就是求解一段区间不同的数字的个数由于数字的种类小于30所以可以用位运算来代表不同的种类 纠结了好久开始一直TLE后来才改的位运算然后用到的就是区间的覆盖问题了#include #include #include #define MAX 100010using namespace原创 2013-08-30 23:56:00 · 646 阅读 · 0 评论 -
poj-1338Ugly Numbers
http://poj.org/problem?id=1338DP 一步一步累乘上去 用三个标记比较大小就行#include#includeusing namespace std;long long a[1501];int n;void read(){ int i,j,k; int a1=1,a2=1,a3=1; a[1]=1; a1=1;原创 2013-08-18 15:59:47 · 717 阅读 · 0 评论 -
poj-1700 Crossing River
http://poj.org/problem?id=1700此题讲的是N个人过河,每个人都有自己的过河时间,一条船只能承受2个人,所用时间为其中过河时间最多的,所以呢,想到有两种情况,第一种:过河时间最少的人来回接送其他人,第二种:过河时间最少和次少的人来回接送其他人,刚开始就觉得第一种时间必然是最少的,但是仔细想想,不然。因为第一种情况虽然单次过河时间少,但送人的次数要多,如第1个人(过河时原创 2013-08-18 19:22:44 · 818 阅读 · 0 评论 -
poj-3051 Satellite Photographs
题目来源:http://poj.org/problem?id=3051直接广度搜索 水~ 练手#include #include #include using namespace std;typedef struct{ int i; int j;}point;point P[80010];int W,H;char a[1010][90];int bf原创 2013-08-17 11:59:04 · 915 阅读 · 0 评论 -
poj-1200 Crazy Search
题目来源:http://poj.org/problem?id=1200遍历一遍 主要是判重 用到hash 不是很难 水~#include #include #include #include #define NUM 257#define N 16000005using namespace std;bool hash[N];int m[NUM];char s原创 2013-08-16 23:52:51 · 1146 阅读 · 0 评论 -
poj-3045 Cow Acrobats
题目链接:http://poj.org/problem?id=3045按weight+strength 排序就行了#include #include #include using namespace std;typedef struct{ int weight; int stregth;} COW;COW cow[50010];int n;int cm原创 2013-08-17 11:21:24 · 1371 阅读 · 0 评论 -
poj-2100 Graveyard Design
题目来源:http://poj.org/problem?id=2100睡前一水 直接暴力 一顿乱搞#include #include #include using namespace std;long long a[1000][2];int main(){ long long n; while(~scanf("%lld",&n)) {原创 2013-08-16 01:24:43 · 969 阅读 · 0 评论 -
poj-2479 简单DP
题目来源:http://poj.org/problem?id=2479题目大意就是求一个数组里面的两端连续值得最大和DP从前往后扫一遍 再从后往前扫一遍然后求1~i 和i+1~n的和的最大值注意题目要求必须得最低取两个数#include #include #define MAXN 50010#define MIN -10000using namespace std;i原创 2013-08-15 23:41:02 · 757 阅读 · 0 评论 -
poj-2601Simple calculations
题目来源:http://poj.org/problem?id=2601给你公式ai = (ai-1 + ai+1)/2 - ci给你a0 、 an+1 和 c1~ cn 要求 a1易推2an=a(n-1) +a(n+1) -2cn;所以 2a1=a0+a2-2c1; 2a2=a1+a3-2c2; :原创 2013-08-16 16:01:09 · 840 阅读 · 0 评论 -
poj-1740 A New Stone Game 博弈论
题目来源:http://poj.org/problem?id=1740刚刚看完博弈论的几篇文章,找了这水题,根据论文里面的思路很清楚了#include //只需要判断它是不是有N对相等的情况#include #include #include using namespace std;bool f[1005];int main(){ int n; whi原创 2013-08-14 21:11:03 · 846 阅读 · 0 评论 -
poj-3903 Stock Exchang O(N*logN)
题目来源:http://poj.org/problem?id=3903睡前水题一道 O(N*logN) 最长上升子序列#include #include #include #define MAXN 100010using namespace std;long long a[MAXN],b[MAXN];int sum=1,n;void find(int x){ in原创 2013-08-14 01:49:54 · 728 阅读 · 0 评论 -
poj-1256 Anagram 全排列
题目来源:http://poj.org/problem?id=1256题目大意是求字符串的全排列 要求按A那就把给定的字符串先排序然后通过STL的next_permutation函数生成全排列(C++)#include #include #include using namespace std;bool cmp(char a, char b){ int a原创 2013-08-14 17:45:35 · 1293 阅读 · 0 评论 -
poj-3261 后缀数组求可重叠的k次最长重复子串
http://poj.org/problem?id=3261根据http://blog.youkuaiyun.com/taceo/article/details/9908545论文由于数据比较大 先离散化求出height数组在二分字符串的长度求解 把height数组分组 看是否存在一组中 存在height[i]大于length k次的 然后进一步求解#include#include原创 2013-08-25 17:05:15 · 910 阅读 · 0 评论 -
poj-3468-A Simple Problem with Integers 线段树lazy标记
http://poj.org/problem?id=3468有了上一题的基础 这题就是小菜了#include #include #include #define MAX 100010using namespace std;typedef struct{ long long l; long long r; long long sum; long l原创 2013-08-11 13:49:04 · 649 阅读 · 0 评论 -
poj-1067 威佐夫博奕 Wythoff Game
http://poj.org/problem?id=1067很明显不懂 直接看了discuss~ 先留着#include #include int ak, bk;double x;int main() { x = (1 + sqrt(5.0)) / 2; while(scanf("%d %d", &ak, &bk) != EOF) { i原创 2013-08-19 15:54:57 · 748 阅读 · 0 评论 -
poj-1013 Counterfeit Dollar
http://poj.org/problem?id=1013题目要求找出轻的或重的硬币#include #include #include #include using namespace std;#define MAX 1000000int ans[13];char rright[12],lleft[12],re[5];void findx(char str1[],cha原创 2013-08-19 14:40:08 · 758 阅读 · 0 评论 -
poj-2406 Power Strings睡前一水~
http://poj.org/problem?id=2406睡前一水~ 一看就觉得是KMP的next数组...然后果然是#include #include #include #define max 1000010int n[max];char str1[max];int next(char s[]){ n[0]=-1; int j=0,k=-1;原创 2013-08-15 00:36:49 · 1208 阅读 · 0 评论