【HDU 6591】
UNSOLVED
【HDU 6592】
UNSOLVED
【HDU 6593】
UNSOLVED
【HDU 6594】
UNSOLVED
【HDU 6595】
SOLED
概率期望,算是一道纯数学题
#include<cstdio> #include<iostream> #define ll long long const int MAXN = 3001; const int mod = 998244353; ll ans[MAXN]; ll qpower(ll a, ll x) { ll res = 1; ll down = a; while (x) { if (x & 1) { res = (res*down) % mod; } down = (down*down) % mod; x = x >> 1; } return res; } void init() { for (int i = 1; i <MAXN; i++) { ans[i] = ((i * (i - 1))%mod)*qpower(3, mod - 2); ans[i] %= mod; ans[i] = (ans[i] + ans[i - 1]) % mod; } for (int i = 1; i < MAXN; i++) { ans[i] = (ans[i] * qpower(i, mod - 2))%mod; } } signed main() { int n; init(); while (~scanf("%d",&n)) { printf("%lld\n", ans[n]); } return 0; }
【HDU 6596】
UNSOLVED
【HDU 6597】
UNSOLVED
不平等博弈
【HDU 6598】
UNSOLVED
建图+网络流
【HDU 6599】
回文
UNSOLVED
【HDU 6600】
UNSOLVED
【HDU 6601】
SOLED
【题目大意】
给定一个长度为n的整数序列,给定m次询问,每次询问区间内整数能够合法组成三角形的最大长度
【思路】
基本上是裸的主席树,找到区间第1大,第2大,第3大,然后计算合法性,如果不合法,找第2大,第3大,第4大,以此类推
因为三角形边长的合法情况是一个斐波那契数列,所以查找次数不会超过44次,时间复杂度较小
【知识点】:主席树
#include<cstdio> #include<iostream> #include<algorithm> #define ll long long using namespace std; const int MAXN = 200010; const int MAXM = 200010; int lsan[MAXN], a[MAXN],T[MAXN]; int sum[21*MAXN], ls[21 * MAXN], rs[21 * MAXN]; int n, m; int cnt; int build(int l, int r) { int root=++cnt; sum[root] = 0; int mid = (l + r) >> 1; if (l < r) { ls[root] = build(l, mid); rs[root] = build(mid + 1, r); } return root; } int update(int pre, int l, int r,int x) { int root=++cnt; sum[root] = sum[pre] + 1; ls[root] = ls[pre]; rs[root] = rs[pre]; int mid = (l + r) >> 1; if (l < r) { if (x <= mid) ls[root] = update(ls[pre], l, mid, x); else rs[root] = update(rs[pre], mid + 1, r,x); } return root; } int query(int l,int r,int x, int y, int num) { if (l >= r) return l; int t = sum[rs[y]] - sum[rs[x]]; int mid = (l + r) >> 1; if (t>=num) return query(mid + 1, r, rs[x], rs[y], num); else return query(l, mid, ls[x], ls[y], num-t); } int main() { while (~scanf("%d%d", &n, &m)) { cnt = 0; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); lsan[i] = a[i]; } sort(lsan + 1, lsan + 1 + n); int maxn = unique(lsan + 1, lsan + 1 + n) - lsan - 1; T[0] = build(1, maxn); for (int i = 1; i <= n; i++) { int t = lower_bound(lsan + 1, lsan + 1 + maxn, a[i]) - lsan; T[i] = update(T[i - 1], 1, maxn, t); } for (int i = 1; i <= m; i++) { int x, y, k; scanf("%d%d", &x, &y); int cal = 0; ll l1=0, l2=0, l3=0; cal = 0; while ((l1 + l2 <= l3 || l1 + l3 <= l2 ||l2 + l3 <= l1) &&cal+3<=y+1-x) { l1 = lsan[query(1, maxn, T[x - 1], T[y], ++cal)]; l2 = lsan[query(1, maxn, T[x - 1], T[y], ++cal)]; l3 = lsan[query(1, maxn, T[x - 1], T[y], ++cal)]; cal -= 2; } if (l1 + l2 > l3 && l1 + l3 > l2 &&l2 + l3 > l1) printf("%lld\n", l1 + l2 + l3); else printf("-1\n"); } } return 0; }
【HDU 6602】
UNSOLVED
线段树
UNSOLVED
原文地址:https://www.cnblogs.com/rentu/p/11241030.html
时间: 2024-10-27 12:52:12