这个dp题很有学问,我也是照着标称写的 还需要学习 补: if(order[i] < order[i-1]) pre[j] += now[j]; 这句的解释 首先order表示的是每个数字排序之后的数组 order[0] 就是最小的那个数字是原来数组哪一个 但是会有等于的情况 所以这里定义的是如果 i < j时 * order[i] > order[j] 意味 A{order[i]] >= A[order[j]] * order[j] < order[j] 意味 A[orde…
题目链接 https://acm.bnu.edu.cn/v3/contest_show.php?cid=8506#problem/A problem description As we know, the NTU Final PK contest usually tends to be pretty hard. Many teams got frustrated when participating NTU Final PK contest. So I decide to make the fi…
题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52310 problem description Define the depth of a node in a rooted tree by applying the following rules recursively: • The depth of a root node is 0. • The depths of child nodes whose parents are with…
题目链接 把左括号看成A右括号看成B,推一下就行了.好久之前写的,推到最后发现是一个有规律的序列. #include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n; while(scanf("%lld",&n)!=EOF) { ll cnt=,sum=; ;; i++) { if(sum>=n) break; cnt++; sum=sum+cnt; //…
题目链接 宽搜一下就行. #include <iostream> #include<cstdio> #include<cstring> #include<queue> using namespace std; int n,m; ][]; ][]={,,-,,,,,-}; ][]; bool check(int x,int y) { ||x>=n||y<||y>=m); ); ; } int prx,pry; struct node { in…
题目链接 #include<cstdio> #include<cstring> #include<algorithm> #include<stack> using namespace std; ]; int cal(int x) { int tx=x; ; while(tx) { &&tx%-pre!=-) ; pre = tx%; tx/=; } return x; } int main() { scanf("%d",&…
题目链接 https://acm.bnu.edu.cn/v3/contest_show.php?cid=8504#problem/C 代码如下: #include <iostream> #include <algorithm> #include <stdio.h> #include <cstring> #include <queue> #include <bitset> #include <set> #include &l…
题目链接 https://acm.bnu.edu.cn/v3/problem_show.php?pid=52305 problem  description In ICPCCamp, there are n cities and (n−1) (bidirectional) roads between cities. The i-th road is between the ai-th and bi-th cities. It is guaranteed that cities are conne…
题目链接 水题,算一下就行. #include <bits/stdc++.h> using namespace std; typedef long long ll; ll x[],y[],z[]; double cal(ll x[]) { ll ans1; ]>=x[]&&x[]<=x[]) ans1=; ]<x[]) ans1=(x[]-x[])*(x[]-x[]); ]>x[]) ans1=(x[]-x[])*(x[]-x[]); return an…
题目链接 很久之前写的了,好像是对拍打表过的,推一下就行了. #include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll a,b,c; scanf("%lld%lld%lld",&a,&b,&c); ll ans=c*; &&b>=)||(a>=)) printf(); &&b==) printf(&…