自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(19)
  • 收藏
  • 关注

原创 威左夫博弈

#include #include using namespace std; //double ans=0.3; int main() { int casenum; scanf("%d",&casenum); for(int i=1;i<=casenum;i++) { int n,k; scanf("%d%d",&n,&k);

2017-07-31 23:03:46 331

原创 poj 3264 (summerIII O) j树状数组 ST表(区间最值查询)

#include #include #include using namespace std; const int maxn= 100000+50; int n,m,a[maxn],mx[maxn][50],mn[maxn][50];//这里mx[maxn][范围内尽量取大一点] void init(){ int m=floor(log((double)n)/log(2.0)); for(i

2017-07-31 22:41:30 257

原创 hdu 2642 (summerIII J) 二维树状数组

#include #include #include using namespace std; const int maxn=4000; int c[maxn][maxn],n; char str[10]; int lowbit(int x) { return x&(-x); } void update(int i,int j,int val) { for(int x=i;x<

2017-07-31 21:08:41 241

原创 1961 2406 poj 求字符串的最小循环子串

#include #include #include using namespace std; const int maxn=1000000+50; char str[maxn],P[maxn]; int casenum=0,next[maxn],num,n; void makeNext(const char P[],int next[]) { int q,k; int m=st

2017-07-31 00:03:26 1527

转载 HDU1556 树状数组,线段树区间更新两种方法(主要树状数组)

树状数组 #include #include const int MAXN=110000; int n,c[MAXN]; int lowbit(int x) //计算2^k { x=x&-x; return x; } void update(int num,int val) //向下查询,num是要更新的子节点,val是要修改的值 { while(num>0)

2017-07-30 00:37:23 320

转载 POJ1703 两种方法

找规律算出子节点与父节点,子节点与爷爷节点的关系来建图。/* D Accepted 916 KB 329 ms C++ 1120 B 2013-04-08 18:29:33 */ #include const int maxn = 100000+10; int p[maxn]; //存父亲节点 int r[maxn]; //存与根节点的关系,0 代表同类, 1代表不同类 int find(i

2017-07-28 09:03:28 424

原创 线段树两题 hdu1166 hdu1754

#include #include #include #include #include using namespace std; const int maxn=200000+50; int n,m,arr[maxn],casenum=0,start,endi,q[maxn],num=0,sum; char str[10]; struct SegTreeNode{ int val; }segTre

2017-07-28 00:10:01 240

转载 CodeForces 660D Number of Parallelograms

You are given n points on a plane. All the points are distinct and no three of them lie on the same line. Find the number of parallelograms with the vertices at the given points. Input The first l

2017-07-26 20:43:30 405

原创 POJ 3268

这道题用djstra方法做,当然也可以用贝尔曼做,开始做的时候被2000ms给骗了,一直TLE后来想想应该只是JAVA 2000ms,c++依然是1s。 现附上TLE的代码,粗略估算应该是10^9,超时了(O(N^3)..... #include #include #include #define INF 0x3f3f using namespace std; const int maxn=1

2017-07-26 15:05:48 304

原创 POJ2139

#include #include #include using namespace std; const int INF=1000000009; int n,m,amount,a[700],dis[700][700]; int ans=INF; void floyd() { //memset(dis,INF,sizeof(dis)); for(int i=1;i<=n;i++)

2017-07-25 21:19:48 429

原创 POJ 2739

开始不知道为什么输入9999多次,cnt会变化,最后在其中加了一个判断,终于AC了,这种题目不知道为什么很容易错,。。,做个记录以后回来看#include #include using namespace std; int prime[1100000],primesize,phi[11000000],m; bool isprime[11000000]; /*bool is_prime(int n)

2017-07-25 19:58:56 261

原创 POJ 3259

本题目属于bellmanford的入门题目,不过要注意的是单双向间的差别,这里提供一种简单的bellman 算法和经过队列优化后的算法,参考算法竞赛和他人的代码。 简单版 #include #include #define MAX 0x3f3f3f using namespace std; const int N=10000+50; int nodenum,original,e

2017-07-25 16:10:08 230

转载 HDOJ2467

#include #include #include using namespace std; const int MAXN=20000+50; int n,m; vector Graph[MAXN]; int TopNum[MAXN], NodeNum[MAXN];; void TopSort(){ queue que; //int cnt2=0; for(int

2017-07-24 21:06:54 332

转载 dfs Preparing Olympiad

#include using namespace std; const int N=1e5+10; int num[N],mum[N]; int n,m,q,t,l,r; int top,ans,cnt; void dfs(int sum,int d,int x,int minn)///和,差值,当前循环,最小数 { if(sum>=l&&sum=q) ans++; if(sum

2017-07-23 18:59:10 297

原创 HDU2612 BFS优化

简单BFS。但是很容易超时 以下贴上TLE和AC 的代码 AC:(别人的代码)#include #include #include #include using namespace std; char map[202][202];//地图 int a[202][202];//保存第一个人Y到各个节点(坐标)的最小步数,有的节点不用访问,下面有说明 int b[202][202];//

2017-07-22 17:04:53 419 1

原创 POJ2566 尺取法巧解

#include #include #include #include #include using namespace std; #define N 100050 #define INF 2000000010//数要开大一点避免溢出 int a[N],ans,n,t,k; struct Node { int v,id; }sum[N]; bool cmp(Node a,Node

2017-07-22 08:58:54 431

转载 五子棋

Alice and Bob play 5-in-a-row game. They have a playing field of size 10 × 10. In turns they put either crosses or noughts, one at a time. Alice puts crosses and Bob puts noughts. In current match th

2017-07-19 22:25:47 263

原创 二分法求最大距离的最小值

#include #include #include using namespace std; long long data[999999],last,next,mid,l,r; int c,n; bool judge(int x) { last=0; for(int i=0;i<c;i++) { next=last+1; int cnt=0;

2017-07-14 23:50:59 1031

原创 三分法求函数最大值(求导求极值)

#include #include using namespace std; double y; double f(double x) { return 6*pow(x,7)+8*pow(x,6)+7*pow(x,3)+5*pow(x,2)-y*x; } double fc(double x) { return 42*pow(x,6)+48*pow(x,5)+21*pow(x,2)

2017-07-13 23:35:58 1202

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除