
POJ
文章平均质量分 57
风中那朵云
2333333
展开
-
POJ2299 Ultra-QuickSort
题目链接:http://poj.org/problem?id=2299 树状数组求逆序对,要先离散 贴代码 var a,b,c,id:array[0..500005]of longint; n:longint; ans:int64; procedure swap(var x,y:longint); var t:longint; begin原创 2016-11-14 12:37:50 · 236 阅读 · 0 评论 -
POJ3090 Visible Lattice Points
题目链接:http://poj.org/problem?id=3090 和一道叫兔八哥什么的题是差不多的 涉及到网格图上的一个问题:判断(x1,y1)和(x2,y2)的连线上有没有其它格点 当gcd(|x1-x2|,|y1-y2|)=1时,是满足要求的 所以就是结合线性筛,用欧拉函数phi搞一搞就好了 贴代码#include#includeusing name原创 2017-07-08 15:14:15 · 249 阅读 · 0 评论 -
POJ1284 Primitive Roots
题目链接:http://poj.org/problem?id=1284 原根,定义题面有 暴力枚举肯定会TLE 找规律,用欧拉函数,答案为phi(n-1) 附:原根的百度百科 一篇关于原根看起来很厉害的博客 鸣谢博主ACdreamerACdreamer原创 2017-07-07 22:02:55 · 234 阅读 · 0 评论 -
POJ2407 Relatives
题目链接:http://poj.org/problem?id=2407 欧拉函数 已知n求phi(n)但是此处n是不包括在内的 贴代码#include#includeusing namespace std;typedef long long ll;int main(){ freopen("2407.in","r",stdin); freopen("2407.out原创 2017-07-07 20:34:23 · 264 阅读 · 0 评论 -
POJ1990 MooFest
题目链接:http://poj.org/problem?id=1990 树状数组,统计的时候显然不可以一对一对地加上去 可以先按照v[i]升序 当前位置前后面分类讨论,所以用两个树状数组,一个统计个数,一个统计距离,可以通过作差计算,注意不要算岔了 贴代码#include#include#include #includeusing namespace std;原创 2017-07-07 17:08:13 · 245 阅读 · 0 评论 -
POJ2029 Get Many Persimmon Trees
题目链接:http://poj.org/problem?id=2029 二维树状数组+容斥 c[i][j]的意义是(i,j)为右下角的前缀和 注意要向上统计,向下修改 注意区别单点修改与区间修改 贴代码#include#includeusing namespace std;int const maxn=105;int c[maxn][maxn];int原创 2017-07-06 22:08:15 · 243 阅读 · 0 评论 -
POJ2155 Matrix
题目链接:http://poj.org/problem?id=2155 树状数组+容斥,注意要向上统计,向下修改 注意c[x][y]的意义是A[i][j]修改后的值 贴代码#include#include#include#includeusing namespace std;int const maxn=1005;int c[maxn][maxn];int Q,原创 2017-07-06 17:00:07 · 248 阅读 · 0 评论 -
POJ3067 Japan
题目链接:http://poj.org/problem?id=3067 求交叉数,先按第一列排序,再对第二列求逆序对 注意会爆int 注意==和=,一不留神写错还没看出来 贴代码#include#include#include#includeint const maxn=1005;int a[maxn*maxn],b[maxn*maxn],c[maxn];i原创 2017-07-06 19:59:18 · 248 阅读 · 0 评论 -
POJ3264 Balanced Lineup
题目链接:http://poj.org/problem?id=3264 RMQ裸题 贴代码 var n,Q:longint; fmax,fmin:array[0..50005,0..20]of longint; function min(x,y:longint):longint; begin if x<y then exit(x) else exit(y);原创 2016-11-14 14:53:03 · 232 阅读 · 0 评论 -
POJ3368 Frequent values
题目链接:http://poj.org/problem?id=3368 RMQ,求的是在一个非降序列中任意区间[L,R]中同一个数出现最多的次数 在正常RMQ的基础上对于两端和中部分别特殊处理 贴代码 var n,Q:longint; a,right,left:array[0..100005]of longint; f:array[0..100005,0.原创 2016-11-14 16:03:09 · 290 阅读 · 0 评论 -
POJ2352 Stars
题目链接:http://poj.org/problem?id=2352 树状数组裸题,求的是前k个数中X≤Xk且Y≤Yk的数对个数恰好为i的k有多少个 贴代码#include#includeusing namespace std;const int maxn=32005;int c[32005],f[15005],n;int lowbit(int x){ return原创 2016-11-13 22:42:39 · 222 阅读 · 0 评论 -
POJ2481 Cows
题目链接:http://poj.org/problem?id=2481 树状数组裸题,求的是把线段i包含的线段有几条,可以有1个端点重合,但是不可以两个端点都重合,注意判重就好 贴代码 const maxn=100005; var a,b,c,id,ans:array[0..maxn]of longint; n:longint; procedure swap(var原创 2016-11-14 09:09:09 · 297 阅读 · 0 评论 -
POJ3321 Apple Tree
题目链接:http://poj.org/problem?id=3321 树状数组裸题,对于每个时间点,设置两个时间戳,分别记录dfs时的进栈时间和出栈时间,前缀和做差就是子数中被标记的个数 贴代码#include#includeusing namespace std;const int maxn=100005;int c[maxn],inn[maxn],oun[maxn],原创 2016-11-14 11:36:34 · 209 阅读 · 0 评论 -
POJ3253 Fence Repair
题目链接:http://poj.org/problem?id=3253 和合并果子一样,小根堆 贴代码#include#includeusing namespace std;typedef long long ll;const int maxn=20005;ll heap[maxn];int len,n;void swap(ll &x,ll &y){ ll t;原创 2017-07-25 10:53:29 · 193 阅读 · 0 评论