摘要: 思路:和求区间内有多少个不同的数一样,只不过改下权值。#include#include#include#include#include#define Maxn 50010#define LL __int64#define lowbit(x) (x&(-x))using namespace std;int pre[1000010],num[Maxn],n;LL ans[Maxn*4],C[Maxn];struct Query{ int i,l,r; int operatorm) break; } /* for(i=1;i<=n;i++) ... 阅读全文
posted @ 2013-10-09 16:32 fangguo 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 思路:枚举+树的直径#include#include#include#include#include#define clr(x,y) memset(x,y,sizeof(x))#define Maxn 3000#define inf 100000000using namespace std;int head[Maxn],Max[Maxn],lMax[Maxn],id[Maxn],road[Maxn],e,n,ans,te;bool vi[Maxn];struct Edge{ int u,v,next,val;}edge[Maxn*2];void init(){ clr(head,-... 阅读全文
posted @ 2013-10-09 15:15 fangguo 阅读(214) 评论(0) 推荐(0) 编辑
摘要: 思路:dp[i]=dp[j]+(num[i]-num[j+1])^2;#include#include#include#include#define Maxn 1000010#define LL unsigned __int64using namespace std;LL dp[Maxn],num[Maxn];int que[Maxn*3];inline int ReadInt(){ char ch = getchar(); int data = 0; while (ch '9') ch = getchar(); do { ... 阅读全文
posted @ 2013-10-09 12:11 fangguo 阅读(213) 评论(0) 推荐(0) 编辑