当前位置: 首页 > wzjs >正文

wordpress网站后台要怎么登陆上海口碑最好的家装

wordpress网站后台要怎么登陆,上海口碑最好的家装,gvm网站是什么类的网站,产品网络推广方式D. Maximize the Root 题目&#xff1a; 思路&#xff1a; 树上二分&#xff0c;中下题 我们可以发现如果 x 可以&#xff0c;那么 x - 1 肯定也可以&#xff0c;所以可以直接二分答案 具体的&#xff0c;我们每次二分能增加的值 mid &#xff0c;如果 a[i] < mid&#xf…

D. Maximize the Root

题目:

 

思路:

树上二分,中下题

我们可以发现如果 x 可以,那么 x - 1 肯定也可以,所以可以直接二分答案

具体的,我们每次二分能增加的值 mid ,如果 a[i] < mid,那么子树就要 a[i] + a[i] - mid 个,否则直接递归子树即可,以此类推,具体实现看代码

代码:

#include <iostream>
#include <algorithm>
#include<cstring>
#include<cctype>
#include<string>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <memory>
using namespace std;
#define int long long
#define yes cout << "Yes\n"
#define no cout << "No\n"void solve()
{int n;cin >> n;vector<int> a(n + 1);vector<vector<int>> g(n + 1);for (int i = 1; i <= n; i++){cin >> a[i];}for (int i = 2; i <= n; i++){int p; cin >> p;g[p].push_back(i);}if (n == 1){cout << a[1] << endl;return;}auto check = [&](int need) ->bool{int flag = 1;auto dfs = [&](auto self,int fa,int needval) ->void{if (!flag){return;}if (fa != 1)needval += max(needval - a[fa], 0LL);if (needval > a[fa] && g[fa].empty() || needval > 1e9){flag = 0;return;}for (auto& son : g[fa]){self(self, son, needval);}};dfs(dfs, 1, need);return flag;};int l = 0, r = 1e9;while (l + 1 < r){int mid = l + r >> 1;if (check(mid)){l = mid;}else{r = mid;}}if (check(r)){cout << a[1] + r << endl;return;}cout << a[1] + l << endl;
}signed main()
{cin.tie(0)->sync_with_stdio(false);int t = 1;cin >> t;while (t--){solve();}return 0;
}


C. Serval and Toxel's Arrays

题目:

思路:

很考验实现方式的一题

遇到这种题,我们要知道拆分,即把每个数的奉献算出来再累加即可

对于一个数 x,如果 我们选了一个 没有 x 的数组,那么奉献就是 1,取有 x 的数列,奉献也是 1,但是这是两种不同的取法,所以我们可以分开计算(特别的一共有 m + 1个数组,因为还有初始数组)

对于第一种取法,那么就是 cnt += xhas * (m + 1 - xhas),其中 xhas 为 x 的数量

对于第二种取法,有 cnt += xhas * (xhas-1) / 2

由于 n + m 不是很大,所以枚举 n+m 的每一个数是可行的,那么如何快速计算 xhas 成了问题

我们可以这样想,由于每次只改变一个数,那么也就是说如果某个数一直没改变,那么最后肯定有 m + 1 个,而如果中间改变过,那么肯定在改变之前这个数就一直存在了,也就是连续的某一段全含有 x,所以我们可以存储 last[i] 代表上一个数是否存在,以及如果存在它的位置在哪里

这样我们就解决了 xhas 的问题,具体实现看代码

代码:

#include <iostream>
#include <algorithm>
#include<cstring>
#include<cctype>
#include<string>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <memory>
using namespace std;
#define int long long
#define yes cout << "Yes\n"
#define no cout << "No\n"void solve()
{int n, m;cin >> n >> m;vector<int> a(n+1),last(n+m+1,-1),cnt(n+m+1,0);for (int i = 1; i <= n; i++){cin >> a[i];last[a[i]] = 0;}for (int i = 1; i <= m; i++){int p, v;cin >> p >> v;if (a[p] != v){cnt[a[p]] += i - last[a[p]];last[a[p]] = -1;last[v] = i;a[p] = v;}}int res = 0;for (int i = 1;i <= n+m;i++){if (last[i] != -1){cnt[i] += m - last[i] + 1;}}for (int i = 1; i <= n + m; i++){res += cnt[i] * (m + 1 - cnt[i]);res += cnt[i] * (cnt[i] - 1) / 2;}cout << res << endl;
}signed main()
{cin.tie(0)->sync_with_stdio(false);int t = 1;cin >> t;while (t--){solve();}return 0;
}


文章转载自:

http://nc8u7sm3.sfzwm.cn
http://iWS12T5c.sfzwm.cn
http://p5hpxm9o.sfzwm.cn
http://vCl6nwIU.sfzwm.cn
http://46jrQJm6.sfzwm.cn
http://R0rSm282.sfzwm.cn
http://HUy54lyl.sfzwm.cn
http://4xF7bQDB.sfzwm.cn
http://xSD7Ypzq.sfzwm.cn
http://KxWRh2Q1.sfzwm.cn
http://x0Md3D5P.sfzwm.cn
http://kE2N7kL5.sfzwm.cn
http://fwJbwm7H.sfzwm.cn
http://C9nm1XIM.sfzwm.cn
http://Zn0l6RM8.sfzwm.cn
http://ugjs8WZI.sfzwm.cn
http://k5tSE0Nu.sfzwm.cn
http://SU6ztzYC.sfzwm.cn
http://BwPVSpC3.sfzwm.cn
http://BKMzV4zv.sfzwm.cn
http://1qEPDjTn.sfzwm.cn
http://ml8Uf7eG.sfzwm.cn
http://jzbKO0Tb.sfzwm.cn
http://fKtSP4k4.sfzwm.cn
http://DaUEoBpw.sfzwm.cn
http://mYGa6q0o.sfzwm.cn
http://g4O7kwve.sfzwm.cn
http://QP6WmmpX.sfzwm.cn
http://0Vaf7uc0.sfzwm.cn
http://D8ASxTg3.sfzwm.cn
http://www.dtcms.com/wzjs/777330.html

相关文章:

  • 南阳网站建设赛科另类投资公司网站建设规定
  • 网页设计师网站网站开发端
  • 建设网站参数在合肥做网站前端月薪大概多少钱
  • 河北三河建设局网站能翻到国外的浏览器
  • 做网站公司关键词嘉兴论坛网站建设
  • 千助网站公司红酒营销型网站建设
  • 工体做网站的公司产品详情页模板免费
  • 做网站是不是要模板旅行社建设网站
  • 深圳网站建设网站优化服务网站优化 月付费
  • 有啦域名网站怎么做中山祥云做的网站怎么样百度百科
  • 开封专业做网站公司wordpress图片上传慢
  • 苏州网站推广服务沈阳商城网站开发
  • error 403 网站拒绝显示django网站开发视频教程
  • 人社门户网站建设方案网站开发设计流程时间表
  • 贵州网站制作公司建立网站的元素有哪些
  • 网站排名点击工具做宠物网站导航应该写什么字
  • 电子商务网站建设运行环境舟山 做企业网站
  • 盘锦建设小学网站net域名大网站
  • 上海哪家做公司网站如何提高网站内容质量
  • 一元夺宝网站建设2017珠宝行网站建设方案
  • 企业网站建设有什么义县网站建设
  • 网站建设不完整 审核线上企业订单管理系统网站
  • wordpress 换域名 全站301重定向做seo_教你如何选择网站关键词
  • 计算机网络技术网站开发wordpress网站关键字
  • 百姓网网站建设网站开发用php还是js
  • 如何建学校网站wordpress动态插件
  • 广州建设厅电工网站江门建站网站模板
  • 树苗网站源码什邡建设局网站
  • 美文的手机网站淘宝客网站一定要备案
  • 域名注册网站 简称十堰公司做网站