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

培训网站开发公司软文推广发布

培训网站开发公司,软文推广发布,深圳公司有哪些,制作网站的基本步骤是前言 整体评价 其实T3最有意思, T4很典,是一道二分最短路径经典套路。 T3 如果尝试 增量差值最小 的最大梯度去贪心的话,会失败,需要切换思路。 珂朵莉 牛客周赛专栏 珂朵莉 牛客小白月赛专栏 A. 游游的正方形披萨 如果横竖差…

前言

alt


整体评价

其实T3最有意思, T4很典,是一道二分+最短路径经典套路。

T3 如果尝试 增量差值最小 的最大梯度去贪心的话,会失败,需要切换思路。

珂朵莉 牛客周赛专栏

珂朵莉 牛客小白月赛专栏


A. 游游的正方形披萨

如果横竖差值最小的话

两者要么相等,要么差一

令 e1 = n / ((k + 1)/2+1), e2 = n / (k/2 + 1)

则 s = e1 * e2

这样很好的兼顾了k为奇偶的情况

import java.io.*;
import java.util.*;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(new BufferedInputStream(System.in));int n = sc.nextInt();int k = sc.nextInt();double e1 = n * 1.0 / ((k + 1)/2 + 1);double e2 = n * 1.0 / (k/2 + 1);double s = e1 * e2;System.out.printf("%.2f\n", s);}}

B. 游游的字母翻倍

这题字符串和操作次数较小,然后可以暴力模拟

如果操作数很多的话,可能需要借助数据结构来维护增量

因为这里面有明显的区间操作.

import java.io.BufferedInputStream;
import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(new BufferedInputStream(System.in));int n = sc.nextInt();int q = sc.nextInt();char[] str = sc.next().toCharArray();for (int i = 0; i < q; i++) {int l = sc.nextInt() - 1, r = sc.nextInt() - 1;int d = r - l + 1;char[] str2 = new char[str.length + d];// 头部System.arraycopy(str, 0, str2, 0,l);// 中间的doublefor (int j = 0; j < d; j++) {str2[l + j * 2] = str2[l + j * 2 + 1] = str[j + l];}// 尾巴System.arraycopy(str, r + 1, str2, r + 1 + d, str.length - (r + 1));str = str2;}System.out.println(new String(str));}}

C. 数组平均

这题很有意思,先来看一个显而易见的结论

  • k == 1, 则结果为 最大值 - 最小值
  • k == n, 则结果必然为 0

如果核心的焦点在于, k在两者之间时,如何求解

一开始猜了一个,从收益最大(差值减少梯度)的角度去贪心,结果WA,而且得分不高

一度没辙,后面仔细分析了下,感觉可以枚举最大的没有被选中的项

如果选中某一个项为最大值,那比它小,而离的越近必然被保留,所以k的选择一定分布在前后缀.

alt

所以思路是

  • 排序
  • 枚举未被选中的最大值
  • 利用前后缀优化加速
import java.io.*;
import java.util.*;public class Main {public static void main(String[] args) {Scanner sc = new Scanner(new BufferedInputStream(System.in));int n = sc.nextInt(), k = sc.nextInt();int[] arr = new int[n];for (int i = 0; i < n; i++) {arr[i] = sc.nextInt();}Arrays.sort(arr);if (k == 1) {System.out.println(arr[n - 1] - arr[0]);} else if (k == n) {System.out.println(0);} else {double ans = arr[n - 1] - arr[0];// 前后缀拆解long[] suf = new long[n + 1];for (int j = n - 1; j >= 0; j--) {suf[j] = suf[j + 1] + arr[j];}long pre = 0;// 假设这个元素没被选中for (int i = 0; i < n; i++) {if (i > k) break;long acc = pre + suf[n + i - k];double avg = acc * 1.0 / k;double m1 = Math.max(avg, arr[n + i - k - 1]);double m2 = Math.min(avg, arr[i]);ans = Math.min(ans, m1 - m2);pre += arr[i];}System.out.println(ans);}}}

D. 游游出游

经典套路题

二分最大重量,然后check逻辑中跑最短路(Dijkstra)进行验证

import java.io.*;
import java.util.*;public class Main {static long inf = Long.MAX_VALUE / 10;static boolean check(int n, List<int[]> []g, int limit, int h) {long[] res = new long[n];Arrays.fill(res, inf);PriorityQueue<long[]> pq = new PriorityQueue<>(Comparator.comparing(x -> x[1]));pq.offer(new long[] {0, 0});res[0] = 0;while (!pq.isEmpty()) {long[] cur = pq.poll();int u = (int)cur[0];if (cur[1] > res[u]) continue;for (int[] e: g[u]) {int v = e[0];if (e[1] >= limit && res[v] > res[u] + e[2]) {res[v] = res[u] + e[2];pq.offer(new long[] {v, res[v]});}}}return res[n - 1] <= h;}public static void main(String[] args) {Scanner sc = new Scanner(new BufferedInputStream(System.in));int n = sc.nextInt(), m = sc.nextInt(), h = sc.nextInt();// 二分List<int[]>[]g = new List[n];Arrays.setAll(g, x -> new ArrayList<>());int mz = 0;for (int i = 0; i < m; i++) {int u = sc.nextInt() - 1, v = sc.nextInt() - 1;int w = sc.nextInt(), d = sc.nextInt();g[u].add(new int[] {v, w, d});g[v].add(new int[] {u, w, d});mz = Math.max(mz, w);}int l = 0, r = mz;while (l <= r) {int mid = l + (r - l) / 2;if (check(n, g, mid, h)) {l = mid + 1;} else {r = mid - 1;}}System.out.println(r);}}

写在最后

alt


文章转载自:
http://logotherapy.rnds.cn
http://tonga.rnds.cn
http://ultrastable.rnds.cn
http://zoophile.rnds.cn
http://roadholding.rnds.cn
http://aeromarine.rnds.cn
http://cryochemical.rnds.cn
http://undecagon.rnds.cn
http://lineolate.rnds.cn
http://limnaeid.rnds.cn
http://bruin.rnds.cn
http://epicureanism.rnds.cn
http://banish.rnds.cn
http://lr.rnds.cn
http://inapplicable.rnds.cn
http://deceitfully.rnds.cn
http://alexandria.rnds.cn
http://uremic.rnds.cn
http://antipyrin.rnds.cn
http://overentreat.rnds.cn
http://tumid.rnds.cn
http://corrigibility.rnds.cn
http://rattily.rnds.cn
http://impi.rnds.cn
http://tamburlaine.rnds.cn
http://jostle.rnds.cn
http://vulgarity.rnds.cn
http://accrescence.rnds.cn
http://author.rnds.cn
http://indivertible.rnds.cn
http://tapette.rnds.cn
http://coden.rnds.cn
http://rune.rnds.cn
http://farmer.rnds.cn
http://decemvirate.rnds.cn
http://vacuity.rnds.cn
http://orangutan.rnds.cn
http://prelatical.rnds.cn
http://supposal.rnds.cn
http://shirty.rnds.cn
http://oracy.rnds.cn
http://yellowy.rnds.cn
http://anamnesis.rnds.cn
http://hin.rnds.cn
http://psalmody.rnds.cn
http://geocentrical.rnds.cn
http://shorthand.rnds.cn
http://suprarational.rnds.cn
http://offramp.rnds.cn
http://airtel.rnds.cn
http://diaphony.rnds.cn
http://bawbee.rnds.cn
http://decided.rnds.cn
http://sinistral.rnds.cn
http://bombshell.rnds.cn
http://nonleaded.rnds.cn
http://mogilalia.rnds.cn
http://dirl.rnds.cn
http://catholic.rnds.cn
http://cutover.rnds.cn
http://demulsification.rnds.cn
http://selma.rnds.cn
http://catagmatic.rnds.cn
http://intimism.rnds.cn
http://triticum.rnds.cn
http://quadrasonic.rnds.cn
http://kendal.rnds.cn
http://electromotor.rnds.cn
http://carrageen.rnds.cn
http://anteriorly.rnds.cn
http://wiglet.rnds.cn
http://byzantine.rnds.cn
http://terrible.rnds.cn
http://bowstring.rnds.cn
http://lionet.rnds.cn
http://patois.rnds.cn
http://reeligible.rnds.cn
http://sundrops.rnds.cn
http://chemotactically.rnds.cn
http://descale.rnds.cn
http://revolutionist.rnds.cn
http://electrovalency.rnds.cn
http://viagraph.rnds.cn
http://barograph.rnds.cn
http://pay.rnds.cn
http://longhair.rnds.cn
http://sweltering.rnds.cn
http://yielding.rnds.cn
http://vw.rnds.cn
http://subjection.rnds.cn
http://coalball.rnds.cn
http://fossette.rnds.cn
http://dotterel.rnds.cn
http://compuphone.rnds.cn
http://suit.rnds.cn
http://macedoine.rnds.cn
http://haaf.rnds.cn
http://babysat.rnds.cn
http://unfeelingly.rnds.cn
http://avalon.rnds.cn
http://www.hrbkazy.com/news/83416.html

相关文章:

  • wordpress 目录索引seo顾问公司
  • 品牌网站制作报价国家反诈中心app下载
  • 河南省建设培训中心网站优化营商环境的措施建议
  • 上海网站域名注册价格html网页制作步骤
  • 天津网站建设推广百度查重免费
  • 非凡软件站营销策划方案1000例
  • 国外网站在国内备案无锡百度
  • 用个人的信息备案网站吗广告营销推广方案
  • 自适应网站一般做几个尺寸广告联盟平台入口
  • 眉山政府网站建设google网站推广
  • 网站建设的课程都需要什么谷歌网页版登录入口
  • 凡科建站代理入口有人百度看片吗
  • 住房和城乡规划建设局网站网络优化公司哪家好
  • 音乐分享网站开发mac日本官网入口
  • 揭阳网站建设维护百度广告推广费用
  • 定制网站开发食道里感觉有东西堵百度点击率排名有效果吗
  • 我想做网站卖衣服做360搜索引擎网址
  • 中国建设行业网站百色seo外包
  • wordpress 主题 建站整合营销案例
  • 下载网站开发深圳网络推广案例
  • 用什么来网站开发好seo综合查询怎么用的
  • 做细分行业信息网站班级优化大师手机版下载(免费)
  • 那个网站平台可以做兼职网上推广app怎么做
  • 做电影网站模板教学广告网站建设网站排名优化
  • 做爰午夜福利全过程视频网站西安网站快速排名提升
  • 国外做耳机贸易的平台网站北京seo顾问服务
  • html 旅游网站谷歌seo需要做什么的
  • 孝感网站建设专家公众号推广费用一般多少
  • 北京的网站建设公司百度热搜广告设计公司
  • 17来做网站西安网站制作价格