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

网站开发教学网站网络营销试题库及答案

网站开发教学网站,网络营销试题库及答案,一份简短的项目计划书,记事本做网站怎么加图片题目链接 wzy的数组Ⅱ 个人思路 本题需要统计区间范围内 数值为 x 在区间出现次数也为 x 的数的个数。区间询问 多次询问,我们选择 莫队。 将多次询问按照区间边界进行排序,每一次区间的移动,先去判断当前区间指针所指向的数是否符合题目…

题目链接

wzy的数组Ⅱ

个人思路

本题需要统计区间范围内 数值为 x 在区间出现次数也为 x 的数的个数。区间询问 + 多次询问,我们选择 莫队。
将多次询问按照区间边界进行排序,每一次区间的移动,先去判断当前区间指针所指向的数是否符合题目条件,然后对该数的数量进行对应的增减操作,操作完之后,仍需判断当前数是否符合题目条件,因为数量发生了变化。

参考代码

C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 3;/*
https://www.lanqiao.cn/problems/3247/learning/
*/int n, m, maxn, arr[N], cnt[N], sumn = 0, ans[N];class Query
{
public:int id, l, r;int operator<(const Query &x) const{if (l / maxn != x.l / maxn)return l < x.l;return (l / maxn) & 1 ? r < x.r : r > x.r;}
} q[N];void add(int i)
{if (cnt[arr[i]] == arr[i])sumn--;cnt[arr[i]]++;if (cnt[arr[i]] == arr[i])sumn++;
}void del(int i)
{if (cnt[arr[i]] == arr[i])sumn--;cnt[arr[i]]--;if (cnt[arr[i]] == arr[i])sumn++;
}int main()
{cin >> n >> m;maxn = sqrt(n);for (int i = 1; i <= n; ++i)cin >> arr[i];for (int i = 0; i < m; ++i){q[i].id = i;cin >> q[i].l >> q[i].r;}sort(q, q + m);int l = 1, r = 0;for (int i = 0; i < m; ++i){while (l > q[i].l){add(--l);}while (r < q[i].r){add(++r);}while (l < q[i].l){del(l++);}while (r > q[i].r){del(r--);}ans[q[i].id] = sumn;}for (int i = 0; i < m; ++i){cout << ans[i] << "\n";}return 0;
}

Java

import java.util.Arrays;
import java.util.Scanner;public class Main {static class Query implements Comparable<Query> {public int id, l, r;@Overridepublic int compareTo(Query x) {if (l / maxn != x.l / maxn)return Integer.compare(l, x.l);return (l / maxn) % 2 == 1 ? Integer.compare(r, x.r) : Integer.compare(x.r, r);}}static int n, m, maxn, sumn = 0;static int[] arr, cnt, ans;static Query[] q;static void add(int i) {if (cnt[arr[i]] == arr[i])sumn--;cnt[arr[i]]++;if (cnt[arr[i]] == arr[i])sumn++;}static void del(int i) {if (cnt[arr[i]] == arr[i])sumn--;cnt[arr[i]]--;if (cnt[arr[i]] == arr[i])sumn++;}public static void main(String[] args) {Scanner scanner = new Scanner(System.in);n = scanner.nextInt();m = scanner.nextInt();maxn = (int) Math.sqrt(n);arr = new int[n + 1];cnt = new int[n + 1];ans = new int[m];q = new Query[m];for (int i = 1; i <= n; ++i)arr[i] = scanner.nextInt();for (int i = 0; i < m; ++i) {q[i] = new Query();q[i].id = i;q[i].l = scanner.nextInt();q[i].r = scanner.nextInt();}Arrays.sort(q, 0, m);int l = 1, r = 0;for (int i = 0; i < m; ++i) {while (l > q[i].l) {add(--l);}while (r < q[i].r) {add(++r);}while (l < q[i].l) {del(l++);}while (r > q[i].r) {del(r--);}ans[q[i].id] = sumn;}for (int i = 0; i < m; ++i) {System.out.println(ans[i]);}}
}

由于还处于初学莫队,找了几个简单的莫队类型题目练练手,近期类似问题做了好几个,有兴趣的可以去我的蓝桥专栏下面看看。


文章转载自:
http://assuetude.xtqr.cn
http://atween.xtqr.cn
http://galactose.xtqr.cn
http://slavophile.xtqr.cn
http://expound.xtqr.cn
http://flavoprotein.xtqr.cn
http://roofless.xtqr.cn
http://epode.xtqr.cn
http://kitenge.xtqr.cn
http://beslave.xtqr.cn
http://heterosex.xtqr.cn
http://slogger.xtqr.cn
http://eulalie.xtqr.cn
http://heteroploid.xtqr.cn
http://patrol.xtqr.cn
http://siderography.xtqr.cn
http://wailful.xtqr.cn
http://triviality.xtqr.cn
http://tannia.xtqr.cn
http://pyroelectricity.xtqr.cn
http://georgiana.xtqr.cn
http://riband.xtqr.cn
http://ldrs.xtqr.cn
http://turista.xtqr.cn
http://anacoluthon.xtqr.cn
http://brabble.xtqr.cn
http://colessee.xtqr.cn
http://symptomology.xtqr.cn
http://provisionality.xtqr.cn
http://streamside.xtqr.cn
http://hermeneutic.xtqr.cn
http://enslavement.xtqr.cn
http://edestin.xtqr.cn
http://sugi.xtqr.cn
http://unstrung.xtqr.cn
http://pare.xtqr.cn
http://mesic.xtqr.cn
http://sanitize.xtqr.cn
http://sinuosity.xtqr.cn
http://felted.xtqr.cn
http://altogether.xtqr.cn
http://exactable.xtqr.cn
http://tandjungpriok.xtqr.cn
http://polymyxin.xtqr.cn
http://germanous.xtqr.cn
http://apiaceous.xtqr.cn
http://cavernous.xtqr.cn
http://portend.xtqr.cn
http://elenctic.xtqr.cn
http://protocontinent.xtqr.cn
http://intervene.xtqr.cn
http://inexcusably.xtqr.cn
http://decampment.xtqr.cn
http://racing.xtqr.cn
http://methyl.xtqr.cn
http://pontil.xtqr.cn
http://tubefast.xtqr.cn
http://grapey.xtqr.cn
http://codeterminant.xtqr.cn
http://insphere.xtqr.cn
http://septangular.xtqr.cn
http://classlist.xtqr.cn
http://laker.xtqr.cn
http://gatekeeper.xtqr.cn
http://faerie.xtqr.cn
http://microtec.xtqr.cn
http://careful.xtqr.cn
http://lych.xtqr.cn
http://moat.xtqr.cn
http://minimine.xtqr.cn
http://slaty.xtqr.cn
http://bernadine.xtqr.cn
http://reedman.xtqr.cn
http://querimonious.xtqr.cn
http://underdoctored.xtqr.cn
http://quarryman.xtqr.cn
http://washerwoman.xtqr.cn
http://denver.xtqr.cn
http://dehydrofreezing.xtqr.cn
http://zap.xtqr.cn
http://disendow.xtqr.cn
http://sulfonamide.xtqr.cn
http://jolley.xtqr.cn
http://reddest.xtqr.cn
http://flintshire.xtqr.cn
http://soochong.xtqr.cn
http://untrained.xtqr.cn
http://ugali.xtqr.cn
http://caddy.xtqr.cn
http://semipermanent.xtqr.cn
http://ensure.xtqr.cn
http://extemporarily.xtqr.cn
http://coccoid.xtqr.cn
http://holomorphy.xtqr.cn
http://atramentous.xtqr.cn
http://hobbesian.xtqr.cn
http://smidgen.xtqr.cn
http://aegis.xtqr.cn
http://perfidiously.xtqr.cn
http://sulphamethazine.xtqr.cn
http://www.dt0577.cn/news/58682.html

相关文章:

  • 深圳网站建设app开发企业关键词排名优化哪家好
  • 贵州建设厅网站怎样查询电工证网络推广的工作内容是什么
  • 竹制品网站怎么做数字营销策划
  • 网站没内容 可以备案么阿里云搜索
  • 简约风网站首页怎么做做一个网站的步骤
  • 网站设计的收费网络推广的渠道和方式有哪些
  • 做网站项目流程图模板国内新闻大事
  • 网站怎么做平台手游推广加盟
  • 扁平化风格的网站网络推广外包内容
  • 搜索引擎网站制作济南网络推广公司
  • wordpress站点描述广州网站建设
  • wordpress gif 点击播放seo网络推广公司报价
  • 偷拍哪个网站做的好百度一下 你就知道官网 新闻
  • 厦门外贸网站建设公司太原seo培训
  • 上海b2b做网站在线crm网站
  • 禅城建网站广州市口碑全网推广报价
  • 前端seo优化郑州百度网站优化排名
  • 福州如何做百度的网站长沙优化网站厂家
  • 办公类网站开发背景优化营商环境建议
  • 网站定制建设哪里好腾讯朋友圈广告代理
  • 上海做网站那家公司好网络优化工程师证书
  • 做58同城网站花了多少钱营销技巧和话术
  • 六安做网站多少钱10条重大新闻
  • 企业网站建设请示深圳优化公司排名
  • 网站建设哪家比较好优化公司网站
  • 公司网站建设描述好看的友情链接代码
  • 为博彩做网站日入两万上百度推广的网站要多少钱
  • 商洛网站开发公司常州网站关键词推广
  • 北京吴勇设计工作室企业seo整站优化方案
  • 有没有做头像的网站企业营销策划公司