*【CodeForces - 799C】Fountains (线段树 或 树状数组,类似二元组问题)

题干:

Arkady plays Gardenscapes a lot. Arkady wants to build two new fountains. There are n available fountains, for each fountain its beauty and cost are known. There are two types of money in the game: coins and diamonds, so each fountain cost can be either in coins or diamonds. No money changes between the types are allowed.

Help Arkady to find two fountains with maximum total beauty so that he can buy both at the same time.

Input

The first line contains three integers nc and d (2 ≤ n ≤ 100 000, 0 ≤ c, d ≤ 100 000) — the number of fountains, the number of coins and diamonds Arkady has.

The next n lines describe fountains. Each of these lines contain two integers bi and pi (1 ≤ bi, pi ≤ 100 000) — the beauty and the cost of the i-th fountain, and then a letter "C" or "D", describing in which type of money is the cost of fountain i: in coins or in diamonds, respectively.

Output

Print the maximum total beauty of exactly two fountains Arkady can build. If he can't build two fountains, print 0.

Examples

Input

3 7 6
10 8 C
4 3 C
5 6 D

Output

9

Input

2 4 5
2 5 C
2 1 D

Output

0

Input

3 10 10
5 5 C
5 5 C
10 11 D

Output

10

Note

In the first example Arkady should build the second fountain with beauty 4, which costs 3 coins. The first fountain he can't build because he don't have enough coins. Also Arkady should build the third fountain with beauty 5 which costs 6 diamonds. Thus the total beauty of built fountains is 9.

In the second example there are two fountains, but Arkady can't build both of them, because he needs 5 coins for the first fountain, and Arkady has only 4 coins.

题目大意:

 

解题报告:

   比赛的时候让这个线段树搞垮我了,,很多特殊情况要考虑,并且,最后卡住我的不是线段树那一块,而是之前的C和D两种货币各选一个的那种情况,我是直接,找到就break,但是其实应该是维护一个最大值。。。因为你直接break的话只能保证cost是可符合的最大的,而保证不了val的最大性!我们需要的是val!(%%%WJH大佬)

AC代码1:

#include<bits/stdc++.h>
using namespace std;
const int MAX = 100000 +5;
int n,c,d,totc,totd;
int cc[MAX];
int dd[MAX];
struct Node{int val,cost;Node(){}Node(int val,int cost):val(val),cost(cost){} 
} C[MAX],D[MAX];
struct TREE {int l,r;int val;
} tree[MAX*4]; 
bool cmp(const Node &a,const Node &b) {return a.cost < b.cost;
}
void pushup(int cur) {tree[cur].val = max(tree[cur*2].val,tree[cur*2+1].val);
}
void buildc(int l,int r,int cur) {tree[cur].l=l;tree[cur].r=r;if(l == r) {tree[cur].val = C[l].val;return ;}int m = (l +r)/2;buildc(l,m,cur*2);buildc(m+1,r,cur*2+1);pushup(cur);
}
void buildd(int l,int r,int cur) {tree[cur].l=l;tree[cur].r=r;if(l == r) {tree[cur].val = D[l].val;return ;}int m = (l +r)/2;buildd(l,m,cur*2);buildd(m+1,r,cur*2+1);pushup(cur);
}
int query(int pl,int pr,int cur) {if(pl <= tree[cur].l && pr >= tree[cur].r) return tree[cur].val;int res = 0;if(pl <= tree[cur*2].r) res = query(pl,pr,cur*2);if(pr >= tree[cur*2+1].l) res = max(res,query(pl,pr,cur*2+1));return res;
}
void update(int tar,int val,int cur) {if(tree[cur].l == tree[cur].r) {tree[cur].val = val;return ;}int m = (tree[cur].l + tree[cur].r)/2;if(tar <= m) update(tar,val,cur*2);else update(tar,val,cur*2+1);pushup(cur);
}
signed main()
{char op[10];int val,cost,flag1=0,flag2=0;cin>>n>>c>>d;for(int i = 1; i<=n; i++) {scanf("%d%d%s",&val,&cost,op);if(op[0] == 'C') {C[++totc] = Node(val,cost);}else {D[++totd] = Node(val,cost);}}sort(C+1,C+totc+1,cmp);	sort(D+1,D+totd+1,cmp);int maxx=0,tmp1 = 0,tmp2 = 0,pos;for(int i = totc; i>=1; i--) {if(C[i].cost <= c) {flag1=1;tmp1 = max(tmp1,C[i].val);}}for(int i = totd; i>=1; i--) {if(D[i].cost <= d) {flag2=1;tmp2 = max(tmp2,D[i].val);}}if(flag1==0 && flag2 == 0) {printf("0\n");return 0;} if(flag1 == 1 && flag2 == 1) {maxx = tmp1 + tmp2;}if(totc == 1 && totd == 1) {if(C[1].cost > c || D[1].cost > d) {printf("0\n");return 0;}}for(int i = 1; i<=totc; i++) cc[i] = C[i].cost;for(int i = 1; i<=totd; i++) dd[i] = D[i].cost;	
//	printf("maxx = %d\n",maxx);//处理Cif(totc != 0 ) {buildc(1,totc,1);for(int i =1; i<=totc; i++) {if(c-cc[i] < 0) break; update(i,0,1);pos = upper_bound(cc+1,cc+totc + 1,c-cc[i]) - cc-1;if(pos == 0) continue;maxx = max(maxx,C[i].val + query(1,pos,1));update(i,C[i].val,1);}}for(int i = 1; i<=MAX; i++) update(i,0,1);
//	printf("%d  %d\n",query(1,1,1),query(1,2,1));if(totd !=0) {buildd(1,totd,1);for(int i =1; i<=totd; i++) {if(d-dd[i] < 0) break;update(i,0,1);pos = upper_bound(dd+1,dd+totd + 1,d-dd[i])- dd -1;if(pos == 0) continue;//		if(dd[pos] > d-dd[i]) pos--;maxx = max(maxx,D[i].val + query(1,pos,1));update(i,D[i].val,1);}}printf("%d\n",maxx);return 0 ;
}
//6 4 9
//6 6 D
//1 4 D
//6 7 C
//7 6 D
//5 7 D
//2 5 D//6 68 40
//1 18 D
//6 16 D
//11 16 D
//7 23 D
//16 30 D
//2 20 D//3 9 5
//10 7 C
//8 6 C
//5 3 C

AC代码2:(o(n^2))

#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int MAX = 1e5 + 5 ;
int n,c,d,ans;
struct Node {int cost,val;char op[5];
} node[MAX];
bool cmp(const Node & a,const Node & b) {if(a.val != b.val) return a.val > b.val;return a.cost < b.cost;
}
int main()
{cin>>n>>c>>d;for(int i = 1; i<=n; i++) {scanf("%d%d%s",&node[i].val,&node[i].cost,node[i].op);}sort(node+1,node+n+1,cmp);int cc,dd,flag,tmp;for(int i = 1; i<=n; i++) {cc = c;dd = d;flag = 0 ;if(node[i].op[0] == 'C' && node[i].cost <= c) {flag=1;cc-=node[i].cost;tmp=node[i].val;}else if(node[i].op[0] == 'D' && node[i].cost <= d) {flag=1;dd-=node[i].cost;tmp = node[i].val;}if(flag == 0) continue;for(int j = i+1; j<=n; j++) {if(node[j].op[0] == 'C' && node[j].cost <= cc) {ans = max(ans,tmp+node[j].val);break;}else if(node[j].op[0] == 'D' && node[j].cost <= dd) {ans = max(ans,tmp+node[j].val);break;}}}printf("%d\n",ans);return 0 ;
}

AC代码3:(树状数组)

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>using namespace std;const int maxn = 100000;int C[maxn+10],D[maxn+10];void add(int *tree,int k,int num)
{while(k<=maxn){tree[k] = max(tree[k],num);k+=k&-k;}
}int read(int *tree,int k)
{int res=0;while(k){res = max(res,tree[k]);k-=k&-k;}return res;
}int main(void)
{int n,c,d,i,j;while(scanf("%d%d%d",&n,&c,&d)==3){memset(C,0,sizeof(C));memset(D,0,sizeof(D));int ans = 0;for(i=1;i<=n;i++){int b,p;char t[5];scanf("%d%d%s",&b,&p,t);int maxn;if(t[0] == 'C'){maxn = read(D,d);if(p > c)continue;maxn = max(maxn,read(C,c-p));add(C,p,b);}else{maxn = read(C,c);if(p > d)continue;maxn = max(maxn,read(D,d-p));add(D,p,b);}if(maxn)ans = max(ans,maxn + b);}cout << ans << endl;}return 0;
}

AC代码4:(tourist)

#include <bits/stdc++.h>using namespace std;const int N = 1234567;int pref[N], a[N], b[N];
char c[N];int solve(vector < pair <int, int> > z, int b) {sort(z.begin(), z.end());int cnt = z.size();if (cnt < 2) {return 0;}pref[0] = 0;for (int i = 0; i < cnt; i++) {pref[i + 1] = max(pref[i], z[i].second);}int i = 0;int res = 0;for (int j = cnt - 1; j >= 0; j--) {while (i < j && z[i].first + z[j].first <= b) {i++;}i = min(i, j);if (i > 0) {res = max(res, pref[i] + z[j].second);}}return res;
}int main() {int n, C, D;scanf("%d %d %d", &n, &C, &D);for (int i = 0; i < n; i++) {scanf("%d %d", a + i, b + i);c[i] = getchar();while (c[i] != 'C' && c[i] != 'D') {c[i] = getchar();}}int ans = 0;{int x = 0, y = 0;for (int i = 0; i < n; i++) {if (c[i] == 'C' && b[i] <= C) {x = max(x, a[i]);}}for (int i = 0; i < n; i++) {if (c[i] == 'D' && b[i] <= D) {y = max(y, a[i]);}}if (x > 0 && y > 0) {ans = max(ans, x + y);}}{vector < pair <int, int> > z;for (int i = 0; i < n; i++) {if (c[i] == 'C') {z.push_back(make_pair(b[i], a[i]));}}ans = max(ans, solve(z, C));}{vector < pair <int, int> > z;for (int i = 0; i < n; i++) {if (c[i] == 'D') {z.push_back(make_pair(b[i], a[i]));}}ans = max(ans, solve(z, D));}printf("%d\n", ans);return 0;
}

AC代码5:(在线搞,以cost建树(而不是排好序后用下标建树),维护最大值)

#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const int maxn = 100010;
int a[maxn],acost[maxn],b[maxn],bcost[maxn];
struct node
{int Max;int l,r;
}t[maxn*4];
void build(int root,int l,int r)
{t[root].l=l;t[root].r=r;//t[root].Max=-1;if(l==r)return;int mid=(l+r)>>1;build(2*root,l,mid);build(2*root+1,mid+1,r);
}
void update(int root,int index,int val)
{int l=t[root].l,r=t[root].r;if(l==r){t[root].Max=max(t[root].Max,val);return;//}int mid=(l+r)>>1;if(index<=mid)update(2*root,index,val);elseupdate(2*root+1,index,val);t[root].Max=max(t[root*2].Max,t[root*2+1].Max);
}
int query(int root,int ql,int qr)
{int l=t[root].l;int r=t[root].r;if(l==ql&&r==qr){return t[root].Max;}int mid=(l+r)>>1;if(qr<=mid)return query(2*root,ql,qr);else if(ql>mid)return query(2*root+1,ql,qr);elsereturn max(query(2*root,ql,mid),query(2*root+1,mid+1,qr));//2*root+1
}
int main()
{int N,C,D;while(~scanf("%d%d%d",&N,&C,&D)){int acnt=0,bcnt=0;char ch;int c,w;int Maxc=-1;for(int i=0;i<N;i++){scanf("%d%d %c",&c,&w,&ch);if(ch=='C'){a[acnt]=c;acost[acnt++]=w;}else if(ch=='D'){b[bcnt]=c;bcost[bcnt++]=w;}Maxc=max(w,Maxc);}int ans=-1;int res1=-1,res2=-1;for(int i=0;i<acnt;i++){if(C>=acost[i])res1=max(res1,a[i]);}for(int i=0;i<bcnt;i++){if(D>=bcost[i])res2=max(res2,b[i]);}if(res1!=-1&&res2!=-1)ans=res1+res2;Maxc=max(Maxc,max(C,D));build(1,1,Maxc+10);for(int i=0;i<acnt;i++){int res=-1;if(C>acost[i])res=query(1,1,C-acost[i]);update(1,acost[i],a[i]);if(res!=-1)ans=max(ans,a[i]+res);}build(1,1,Maxc);for(int i=0;i<bcnt;i++){int res=-1;if(D>bcost[i])res=query(1,1,D-bcost[i]);update(1,bcost[i],b[i]);if(res!=-1)ans=max(ans,b[i]+res);}if(ans!=-1)printf("%d\n",ans);elseprintf("0\n");}
}

AC代码6:(维护最大价值和次大价值 + 前缀和)(感觉这个题解有问题?)

#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
#define rep(i,a,b) for (int i=a; i<=b; ++i)
#define per(i,b,a) for (int i=b; i>=a; --i)
#define mes(a,b)  memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
#define MP make_pair
#define PB push_back
#define fi  first
#define se  second
#define PII  pair<ll , ll >
typedef long long ll;
const int N = 100005;int n;
ll  C, D;
PII  c[N], d[N];
ll ans1[N][2], ans2[N][2];
int  cnt1=0, cnt2=0;
//init函数中均可加等号
void Init()
{sort(c+1, c+1+cnt1);sort(d+1, d+1+cnt2);ll mx1=0, mx2=0;rep(i,1,cnt1){if(mx1 < c[i].se){mx2=mx1,  mx1=c[i].se;ans1[c[i].fi][0]=mx1;ans1[c[i].fi][1]=mx2;}else if(mx2 < c[i].se){mx2=c[i].se;ans1[c[i].fi][0]=mx1;//可注释ans1[c[i].fi][1]=mx2;}}mx1=0, mx2=0;rep(i,1,cnt2){if(mx1 < d[i].se){mx2=mx1,  mx1=d[i].se;ans2[d[i].fi][0]=mx1;ans2[d[i].fi][1]=mx2;}else if(mx2 < d[i].se){mx2=d[i].se;ans2[d[i].fi][0]=mx1;//可注释ans2[d[i].fi][1]=mx2;}}rep(i,1,max(C,D)) rep(j,0,1){ans1[i][j]=max(ans1[i][j], ans1[i-1][j]);ans2[i][j]=max(ans2[i][j], ans2[i-1][j]);}
}
int main()
{scanf("%d%lld%lld", &n, &C, &D);ll bi, pi;    char ch;rep(i,1,n){scanf("%lld%lld%*c%c", &bi, &pi, &ch);if(ch=='C') c[++cnt1]=MP(pi, bi);else d[++cnt2]=MP(pi, bi);}Init();ll sum1=0;if(ans1[C][0] && ans2[D][0])sum1 = max(sum1, ans1[C][0]+ans2[D][0]);ll sum2=0, sum3=0;rep(i,1,cnt1){ll  ret=C-c[i].fi;if(ret>0){if(ans1[ret][0]==c[i].se){if(ans1[ret][1])sum2 = max(sum2, c[i].se+ans1[ret][1]);}else{if(ans1[ret][0])sum2 = max(sum2, c[i].se+ans1[ret][0]);}}}rep(i,1,cnt2){ll  ret=D-d[i].fi;if(ret>0){if(ans2[ret][0]==d[i].se){if(ans2[ret][1])sum3 = max(sum3, d[i].se+ans2[ret][1]);}else{if(ans2[ret][0])sum3 = max(sum3, d[i].se+ans2[ret][0]);}}}printf("%lld\n", max(sum1, max(sum2, sum3)));return 0;
}

AC代码7:(还是自己写的那个线段树,只是将upperbound部分进行了优化,快了将近50ms)

#include<bits/stdc++.h>
using namespace std;
const int MAX = 100000 +5;
int n,c,d,totc,totd;
int cc[MAX];
int dd[MAX];
struct Node{int val,cost;Node(){}Node(int val,int cost):val(val),cost(cost){} 
} C[MAX],D[MAX];
struct TREE {int l,r;int val;
} tree[MAX*4]; 
bool cmp(const Node &a,const Node &b) {if(a.cost != b.cost)return a.cost < b.cost;return a.val > b.val;
}
void pushup(int cur) {tree[cur].val = max(tree[cur*2].val,tree[cur*2+1].val);
}
void buildc(int l,int r,int cur) {tree[cur].l=l;tree[cur].r=r;if(l == r) {tree[cur].val = C[l].val;return ;}int m = (l +r)/2;buildc(l,m,cur*2);buildc(m+1,r,cur*2+1);pushup(cur);
}
void buildd(int l,int r,int cur) {tree[cur].l=l;tree[cur].r=r;if(l == r) {tree[cur].val = D[l].val;return ;}int m = (l +r)/2;buildd(l,m,cur*2);buildd(m+1,r,cur*2+1);pushup(cur);
}
int query(int pl,int pr,int cur) {if(pl <= tree[cur].l && pr >= tree[cur].r) return tree[cur].val;int res = 0;if(pl <= tree[cur*2].r) res = query(pl,pr,cur*2);if(pr >= tree[cur*2+1].l) res = max(res,query(pl,pr,cur*2+1));return res;
}
void update(int tar,int val,int cur) {if(tree[cur].l == tree[cur].r) {tree[cur].val = val;return ;}int m = (tree[cur].l + tree[cur].r)/2;if(tar <= m) update(tar,val,cur*2);else update(tar,val,cur*2+1);pushup(cur);
}
int main()
{char op[10];int val,cost,flag1=0,flag2=0;cin>>n>>c>>d;for(int i = 1; i<=n; i++) {scanf("%d%d%s",&val,&cost,op);if(op[0] == 'C') {C[++totc] = Node(val,cost);}else {D[++totd] = Node(val,cost);}}sort(C+1,C+totc+1,cmp);	sort(D+1,D+totd+1,cmp);int maxx=0,tmp1 = 0,tmp2 = 0,pos;for(int i = totc; i>=1; i--) {if(C[i].cost <= c) {flag1=1;tmp1 = max(tmp1,C[i].val);}}for(int i = totd; i>=1; i--) {if(D[i].cost <= d) {flag2=1;tmp2 = max(tmp2,D[i].val);}}if(flag1==0 && flag2 == 0) {printf("0\n");return 0;} if(flag1 == 1 && flag2 == 1) {maxx = tmp1 + tmp2;}if(totc == 1 && totd == 1) {if(C[1].cost > c || D[1].cost > d) {printf("0\n");return 0;}}for(int i = 1; i<=totc; i++) cc[i] = C[i].cost;for(int i = 1; i<=totd; i++) dd[i] = D[i].cost;
//	printf("maxx = %d\n",maxx);//处理Cif(totc != 0 ) {buildc(1,totc,1);for(int i =1; i<totc; i++) {if(c-cc[i] < 0) break; 
//			update(i,0,1);pos = upper_bound(cc+i+1,cc+totc + 1,c-cc[i]) - (cc/*+i*/)-1;if(pos == i) continue;maxx = max(maxx,C[i].val + query(i+1,pos,1));
//			update(i,C[i].val,1);}}
//	printf("%d  %d\n",query(1,1,1),query(1,2,1));if(totd !=0) {buildd(1,totd,1);for(int i =1; i<totd; i++) {if(d-dd[i] < 0) break;
//			update(i,0,1);pos = upper_bound(dd+i+1,dd+totd + 1,d-dd[i])- (dd/*+i*/) -1;if(pos == i) continue;//		if(dd[pos] > d-dd[i]) pos--;maxx = max(maxx,D[i].val + query(i+1,pos,1));
//			update(i,D[i].val,1);}}printf("%d\n",maxx);return 0 ;
}
//6 4 9
//6 6 D
//1 4 D
//6 7 C
//7 6 D
//5 7 D
//2 5 D//6 68 40
//1 18 D
//6 16 D
//11 16 D
//7 23 D
//16 30 D
//2 20 D//3 9 5
//10 7 C
//8 6 C
//5 3 C

总结:

    对于这一道经典的题目,我想,可以总结的东西还是很多的。

   对于任何数据结构(包括线段树等,包括栈队列等),首先需要看的就是能否进入,或者说,这项功能能否执行  的问题。比如栈,进行pop和top操作的时候要想,是否需要先判断是否栈为空呢?因为为空了就没法进行操作了呀。同理,对于线段树,我们也要想,我们能否建树呢?建树后,能否进行查询呢?即,这个传参是合法的吗?(这两条思考,分别对应了AC代码1中的,if(totc!=0),,,,if(c-cc[i] < 0) break; 这两句)

   其次是这一块的处理,也经常容易忽略:(一个比较可行的解决办法就是自己造数据的时候这些边界情况都考虑一下)(好像说了一堆废话)

	if(flag1==0 && flag2 == 0) {printf("0\n");return 0;} if(flag1 == 1 && flag2 == 1) {maxx = tmp1 + tmp2;}if(totc == 1 && totd == 1) {if(C[1].cost > c || D[1].cost > d) {printf("0\n");return 0;}}

将ac代码1修改成AC代码7:

     改1:for(int i =1; i<totc; i++) {

     改2:if(pos == i) continue;

     改3:maxx = max(maxx,C[i].val + query(i+1,pos,1));//这里query中是从i+1开始的

     改4:每个for中都可以注释掉两个update函数。(因为就没用了)

 

还有一些可总结的:

    lowerbound  upperbound的时候,如果不是对整个数列进行,比如是对[ l , r ]进行,那么upper的可能值就是[ l , r+1 ]这个区间内的值。(即upper出来的pos,肯定大于等于l,小于等于r+1),同理 lowerbound出来的值略有不同,区间是[ l , r ](我感觉是这样?)

   还有就是,对[ l , r ]进行的时候,但是还是要 -a  而不是-(a+i-1)  也就是int pos = lower_bound(a+i,a+i+1,val) - a;这样就可以,因为你最后需要的还是在原数组中的下标呀。

  总之做题还是要在仔细一些吧。

另一个代码:https://blog.csdn.net/SSimpLe_Y/article/details/71702915

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/441719.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

java 前后的区别_java中前后++的区别

java中前后的区别发布时间&#xff1a;2020-06-22 14:38:22来源&#xff1a;亿速云阅读&#xff1a;134作者&#xff1a;Leah这篇文章将为大家详细讲解有关java中前后的区别&#xff0c;小编觉得挺实用的&#xff0c;因此分享给大家做个参考&#xff0c;希望大家阅读完这篇文章…

【CodeForces - 735A 】Ostap and Grasshopper (水题,模拟)

题干&#xff1a; On the way to Rio de Janeiro Ostap kills time playing with a grasshopper he took with him in a special box. Ostap builds a line of length n such that some cells of this line are empty and some contain obstacles. Then, he places his grassh…

java私有成员的访问_java – 使用私有成员或公共访问器的方法

我意识到这可能无法回答,但我正在寻找是否有关于是否直接使用私有成员或类方法中的公共访问器的某种指导.例如,考虑以下代码(在Java中,但在C中看起来非常相似)&#xff1a;public class Matrix {// Private Membersprivate int[][] e;private int numRows;private int numCols;…

☆【CodeForces - 764C】Timofey and a tree (思维题,树的性质)

题干&#xff1a; Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so that the i-th vertex gets color ci. Now its time for Timofey birthday, and his mother asked him to re…

java中实现线程互斥的关键词_简单的互斥同步方式——synchronized关键字详解

2. synchronized的原理和实现细节2.1 synchronized可以用在那些地方静态方法,锁对象为当前类的class对象,不用显式指定实例方法,锁对象为当前实例对象,不用显式指定同步代码块,锁对象为括号中指定的对象&#xff0c;必须显式指定被synchronized修饰的方法或者代码块,同一时刻只…

【51nod - 1875】 丢手绢(约瑟夫问题,可打表,用STL模拟)

题干&#xff1a; 六一儿童节到了&#xff0c;小朋友们在玩丢手绢的游戏。总共有C个小朋友&#xff0c;编号从1到C&#xff0c;他们站成一个圈&#xff0c;第i(1<i<C)个人的左边是i-1&#xff0c;第1个人的左边是C。第i(1<i<C)个人的右边是i1&#xff0c;第C个人的…

mysql server远程连接_本地远程连接 MySQL server

问题MySql Server 出于安全方面考虑默认只允许本机(localhost, 127.0.0.1)来连接访问。如果想远程访问&#xff0c;需要额外做下操作。配置修改定位文件/etc/mysql/mysql.conf.d/mysqld.cnf定位属性skip-networking #注释掉 因为它是屏蔽掉一切TCP/IP连接bind-address 127.0.0…

关闭VS警告#pragma warning(disable:4996)

代码实现&#xff1a; #pragma warning(disable:4996) 1. #pragma warning只对当前文件有效&#xff08;对于.h&#xff0c;对包含它的cpp也是有效的&#xff09;&#xff0c;而不是对整个工程的所有文件有效。当该文件编译结束&#xff0c;设置也就失去作用。 2. #pragma wa…

【CodeForces - 608C】Chain Reaction (二分 或 dp ,思维)

题干&#xff1a; 题目大意&#xff1a; 题意是在一条直线上坐落着不同位置的灯塔&#xff0c;每一个灯塔有自己的power level&#xff0c;当作是射程范围。现在从最右边的灯塔开始激发&#xff0c;如果左边的灯塔在这个灯塔的范围之内&#xff0c;那么将会被毁灭。否则会被激…

java关闭文本_如何更优雅的关闭java文本、网络等资源

通常在 java 中对文本、网络资源等操作起来是很繁杂的&#xff0c;要声明&#xff0c;读取&#xff0c;关闭三个阶段&#xff0c;还得考虑异常情况。假设我们要读取一段文本显示到控制台&#xff0c;通常会有如下的代码&#xff1a;public static void main(String[] args) {Fi…

java类匿名类实例_Java匿名类,匿名内部类实例分析

本文实例讲述了Java匿名类&#xff0c;匿名内部类。分享给大家供大家参考&#xff0c;具体如下&#xff1a;本文内容&#xff1a;内部类匿名类首发日期 &#xff1a;2018-03-25内部类&#xff1a;在一个类中定义另一个类&#xff0c;这样定义的类称为内部类。【包含内部类的类可…

【HDU - 6441】Find Integer (费马大定理 + 奇偶数列法构造勾股定理)

题干&#xff1a; people in USSS love math very much, and there is a famous math problem . give you two integers nn,aa,you are required to find 22 integers bb,cc such that ananbncnbncn. Input one line contains one integer TT;(1≤T≤1000000)(1≤T≤100000…

dart与java互调_Dart与Java不同的地方

数据类型基类是num数值型的操作运算符&#xff1a; 、 - 、* 、/ 、 ~/ 、 %/ 除法 整数余数~/ 除法 取整% 取余常用属性&#xff1a; isNaN、isEven、isOdd (是否非数字、奇偶)常用方法&#xff1a;abs()、round()、floorl()、ceil()、toInt()、toDouble()double nan 0.0 / 0…

算法学习 母函数

母函数又称生成函数。定义是给出序列:a0,a1,a2,.......ak,......,那么函数G(x)a0a1*xa2*x2......ak*xk称为序列a0,a1,a2,.......ak,......的母函数(即生成函数)。 例如&#xff1a;序列1,2,3.......n的生成函数为&#xff1a;G(x)x2x23x3........nxn。点此链接:百度百科 特别…

plsq卸载 删除注册表、_win10操作系统下oracle11g客户端/服务端的下载安装配置卸载总结...

win10操作系统下oracle11g客户端/服务端的下载安装配置卸载总结一&#xff1a;前提注意&#xff1a;现在有两种安装的方式1. oracle11g服务端(64位)oracle客户端(32位)plsql(32位)2. oracle11g服务端(32位)plsql(32位)这里我选择的是第二种 原因是 &#xff1a;首先需要明确ora…

【HDU -1568】 Fibonacci(斐波那契通项公式+取对数)

Fibonacci Problem Description 2007年到来了。经过2006年一年的修炼&#xff0c;数学神童zouyu终于把0到100000000的Fibonacci数列 (f[0]0,f[1]1;f[i] f[i-1]f[i-2](i>2))的值全部给背了下来。 接下来&#xff0c;CodeStar决定要考考他&#xff0c;于是每问他一个数字&a…

java sqlserver分页查询_实现sqlserver分页查询语句

实现sqlserver分页查询语句sqlServer&#xff1a;一次查询&#xff0c;数据库只返回一页的数据。而不是取出所有的数据。pagesize&#xff1a; 每页显示记录数cureentpage&#xff1a;当前页数select * from ( select TOP pagesize * from ( SELECT TOP pagesize*cureentpage…

【HDU - 1269】迷宫城堡 (tarjan算法模板)

题干&#xff1a; 为了训练小希的方向感&#xff0c;Gardon建立了一座大城堡&#xff0c;里面有N个房间(N<10000)和M条通道(M<100000)&#xff0c;每个通道都是单向的&#xff0c;就是说若称某通道连通了A房间和B房间&#xff0c;只说明可以通过这个通道由A房间到达B房间…

php5.4 curl,PHP5.0~5.6 各版本兼容性cURL文件上传功能实例分析

本文实例分析了PHP5.0~5.6 各版本兼容性cURL文件上传功能。分享给大家供大家参考&#xff0c;具体如下&#xff1a;最近做的一个需求&#xff0c;要通过PHP调用cURL&#xff0c;以multipart/form-data格式上传文件。踩坑若干&#xff0c;够一篇文章了。重要警告没事不要读PHP的…

【HDU - 1518】Square (经典的dfs + 剪枝)

题干&#xff1a; Given a set of sticks of various lengths, is it possible to join them end-to-end to form a square? Input The first line of input contains N, the number of test cases. Each test case begins with an integer 4 < M < 20, the number …