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

移动端网站开发环境千锋教育官方网

移动端网站开发环境,千锋教育官方网,wordpress经典编辑器插件,北京海淀网站制作公司前言 整体评价 T5, T6有点意思&#xff0c;这场小白入门场&#xff0c;好像没真正意义上的签到&#xff0c;整体感觉是这样。 A. 召唤神坤 思路: 前后缀拆解 #include <iostream> #include <algorithm> #include <vector> using namespace std;int main()…

前言

在这里插入图片描述


整体评价

T5, T6有点意思,这场小白入门场,好像没真正意义上的签到,整体感觉是这样。


A. 召唤神坤

思路: 前后缀拆解

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;int main()
{// 请在此输入您的代码int n;cin >> n;vector<int> arr(n);for (int i = 0; i < n; i++) {cin >> arr[i];}vector<int> pre(n);vector<int> suf(n);pre[0] = -1;for (int i = 1; i < n; i++) {pre[i] = max(arr[i - 1], pre[i - 1]);}suf[n - 1] = -1;for (int i = n - 2; i >= 0; i--) {suf[i] = max(arr[i + 1], suf[i + 1]);}int res = 0;for (int i = 1; i < n - 1; i++) {res = max(res, (pre[i] + suf[i]) / arr[i]);}cout << res << endl;return 0;
}

B. 聪明的交换策略

思路: 模拟+枚举

#include <bits/stdc++.h>
using namespace std;int main()
{// 请在此输入您的代码int n;cin >> n;string s;cin >> s;// long long res = 1LL << 60;long long acc1 = 0, acc2 = 0;int t0 = 0, t1 = 0;for (int i = 0; i < n;i++) {char c = s[i];if (c == '0') {acc1 += (i - t0);t0++;} else {acc2 += (i - t1);t1++;}}cout << min(acc1, acc2) << endl;return 0;
}

C. 怪兽突击

思路: 枚举

#include <bits/stdc++.h>
using namespace std;
int main()
{// 请在此输入您的代码int n, k;cin >> n >> k;vector<int> arr(n), brr(n);for (int i = 0; i < n; i++) {cin >> arr[i];}for (int i = 0; i < n; i++) {cin >> brr[i];}long long res = 1LL << 60;long long pre = 0;long long mv = arr[0] + brr[0];for (int i = 0; i < n; i++) {if (i + 1 > k) break;pre += arr[i];mv = min(mv, (long long)arr[i] + brr[i]);res = min(res, pre + (k - i - 1) * mv);}cout << res << endl;return 0;
}

D. 蓝桥快打

思路: 二分

#include <bits/stdc++.h>
using namespace std;using int64 = long long;int main()
{// 请在此输入您的代码int t;cin >> t;while (t-- > 0) {int a, b, c;cin >> a >> b >> c;// 可以二分的int l = 1, r = b;while (l <= r) {int m = l + (r - l) / 2;// *) int times = (b + m - 1) / m;if ((int64)(times - 1) * c < a) {r = m - 1;} else {l = m + 1;}   }cout << l << endl;}return 0;}

E. 奇怪的段

思路: 单调队列优化的DP

这题只需要维护最大值就行,不需要维护单调队列

其核心是如下的公式

d p [ i ] [ j ] = max ⁡ t = 0 t = j − 1 d p [ i − 1 ] [ t ] + ( p r e [ j + 1 ] − p r e [ t ] ) ∗ w [ i ] dp[i][j] = \max_{t=0}^{t=j-1} dp[i - 1][t] + (pre[j + 1] - pre[t]) * w[i] dp[i][j]=t=0maxt=j1dp[i1][t]+(pre[j+1]pre[t])w[i]

公式拆解后

d p [ i ] [ j ] = max ⁡ t = 0 t = j − 1 ( d p [ i − 1 ] [ t ] − p r e [ t ] ) ∗ w [ i ] ) + p r e [ j ] ∗ w [ i ] dp[i][j] = \max_{t=0}^{t=j-1}(dp[i - 1][t] - pre[t]) * w[i]) + pre[j] * w[i] dp[i][j]=t=0maxt=j1(dp[i1][t]pre[t])w[i])+pre[j]w[i]

这样这个递推的时间代价为 O ( 1 ) O(1) O(1),而不是 O ( n ) O(n) O(n)

这样总的时间复杂度为 O ( n ∗ k ) O(n * k) O(nk)


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;public class Main {public static void main(String[] args) {AReader sc = new AReader();int n = sc.nextInt(), p = sc.nextInt();int[] arr = new int[n];long[] pre = new long[n + 1];for (int i = 0; i < n; i++) {arr[i] = sc.nextInt();pre[i + 1] = pre[i] + arr[i];}int[] ws = new int[p];for (int i = 0; i < p; i++) {ws[i] = sc.nextInt();}// *)long inf = Long.MIN_VALUE / 10;long[][] dp = new long[p + 1][n];for (int i = 0; i <= p; i++) {Arrays.fill(dp[i], inf);}for (int i = 0; i < n; i++) {dp[1][i] = pre[i + 1] * ws[0];}// O(n)// dp[i - 1][j] - p * pre[j + 1] + p * pre[j]for (int i = 2; i <= p; i++) {long tmp = dp[i - 1][0] - ws[i - 1] * pre[1];for (int j = 1; j < n; j++) {dp[i][j] = tmp + ws[i - 1] * pre[j + 1];tmp = Math.max(tmp, dp[i - 1][j] - ws[i - 1] * pre[j + 1]);}}System.out.println(dp[p][n - 1]);}staticclass AReader {private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));private StringTokenizer tokenizer = new StringTokenizer("");private String innerNextLine() {try {return reader.readLine();} catch (IOException ex) {return null;}}public boolean hasNext() {while (!tokenizer.hasMoreTokens()) {String nextLine = innerNextLine();if (nextLine == null) {return false;}tokenizer = new StringTokenizer(nextLine);}return true;}public String nextLine() {tokenizer = new StringTokenizer("");return innerNextLine();}public String next() {hasNext();return tokenizer.nextToken();}public int nextInt() {return Integer.parseInt(next());}public long nextLong() {return Long.parseLong(next());}//        public BigInteger nextBigInt() {
//            return new BigInteger(next());
//        }// 若需要nextDouble等方法,请自行调用Double.parseDouble包装}}

F. 小蓝的反击

思路: 滑窗 + 三指针

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.StringTokenizer;public class Main {static List<int[]> split(int v) {List<int[]> res = new ArrayList<>();for (int i = 2; i <= v / i; i++) {if (v % i == 0) {int cnt = 0;while (v % i == 0) {v /= i;cnt++;}res.add(new int[] {i, cnt});}}if (v > 1) {res.add(new int[] {v, 1});}return res;}// *)static boolean check(int[][] pre, int s, int e, List<int[]> xx) {for (int i = 0; i < xx.size(); i++) {int tn = xx.get(i)[1];if (pre[i][e + 1] - pre[i][s] < tn) return false;}return true;}public static void main(String[] args) {AReader sc = new AReader();int n = sc.nextInt();int a = sc.nextInt();int b = sc.nextInt();int[] arr = new int[n];for (int i = 0; i < n; i++) {arr[i] = sc.nextInt();}if (b == 1) {System.out.println(0);return;}List<int[]> facs1 = split(a);int m1 = facs1.size();List<int[]> facs2 = split(b);int m2 = facs2.size();// 三指针做法
//        int[][] brr1 = new int[m1][n];int[][] pre1 = new int[m1][n + 1];//        int[][] brr2 = new int[m2][n];int[][] pre2 = new int[m2][n + 1];for (int i = 0; i < n; i++) {int v = arr[i];for (int j = 0; j < m2; j++) {int p = facs2.get(j)[0];int tmp = 0;while (v % p == 0) {v /= p;tmp++;}
//                brr2[j][i] = tmp;pre2[j][i + 1] = pre2[j][i] + tmp;}v = arr[i];for (int j = 0; j < m1; j++) {int p = facs1.get(j)[0];int tmp = 0;while (v % p == 0) {v /= p;tmp++;}
//                brr1[j][i] = tmp;pre1[j][i + 1] = pre1[j][i] + tmp;}}long res = 0;int k1 = 0, k2 = 0;for (int k3 = 0; k3 < n; k3++) {// 找到不满足的点为止while (k1 <= k3 && check(pre1, k1, k3, facs1)) {k1++;}//while (k2 <= k3 && check(pre2, k2, k3, facs2)) {k2++;}//            res += Math.min(k1, k2);// 0 - k1 - 1// k2 -> nres += (k2 <= k1 - 1) ? (k1 - k2): 0;}System.out.println(res);}staticclass AReader {private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));private StringTokenizer tokenizer = new StringTokenizer("");private String innerNextLine() {try {return reader.readLine();} catch (IOException ex) {return null;}}public boolean hasNext() {while (!tokenizer.hasMoreTokens()) {String nextLine = innerNextLine();if (nextLine == null) {return false;}tokenizer = new StringTokenizer(nextLine);}return true;}public String nextLine() {tokenizer = new StringTokenizer("");return innerNextLine();}public String next() {hasNext();return tokenizer.nextToken();}public int nextInt() {return Integer.parseInt(next());}public long nextLong() {return Long.parseLong(next());}//        public BigInteger nextBigInt() {
//            return new BigInteger(next());
//        }// 若需要nextDouble等方法,请自行调用Double.parseDouble包装}}

写在最后

在这里插入图片描述


文章转载自:
http://conkers.spbp.cn
http://merrie.spbp.cn
http://fixer.spbp.cn
http://snowbank.spbp.cn
http://honewort.spbp.cn
http://smokebell.spbp.cn
http://unduly.spbp.cn
http://walty.spbp.cn
http://honeydew.spbp.cn
http://lampoon.spbp.cn
http://burletta.spbp.cn
http://trypsinization.spbp.cn
http://poster.spbp.cn
http://deodorize.spbp.cn
http://perpent.spbp.cn
http://tightknit.spbp.cn
http://micromole.spbp.cn
http://instructive.spbp.cn
http://alai.spbp.cn
http://slimnastics.spbp.cn
http://humper.spbp.cn
http://prograde.spbp.cn
http://horrifiedly.spbp.cn
http://millepede.spbp.cn
http://dubitation.spbp.cn
http://derris.spbp.cn
http://washingtonian.spbp.cn
http://hearting.spbp.cn
http://saccharise.spbp.cn
http://syzygy.spbp.cn
http://dildo.spbp.cn
http://inorganization.spbp.cn
http://joy.spbp.cn
http://unprocurable.spbp.cn
http://kepi.spbp.cn
http://plenism.spbp.cn
http://bughouse.spbp.cn
http://typhoidal.spbp.cn
http://editorship.spbp.cn
http://ratty.spbp.cn
http://inconvertible.spbp.cn
http://scapegoat.spbp.cn
http://vietnik.spbp.cn
http://mccoy.spbp.cn
http://faux.spbp.cn
http://tyrrhenian.spbp.cn
http://decarock.spbp.cn
http://pac.spbp.cn
http://nearly.spbp.cn
http://nilotic.spbp.cn
http://consubstantial.spbp.cn
http://restfully.spbp.cn
http://catechist.spbp.cn
http://moan.spbp.cn
http://airworthy.spbp.cn
http://unfetter.spbp.cn
http://pokeroot.spbp.cn
http://thaumaturge.spbp.cn
http://zeiss.spbp.cn
http://disubstituted.spbp.cn
http://rocky.spbp.cn
http://tocometer.spbp.cn
http://garishly.spbp.cn
http://blanche.spbp.cn
http://wonsan.spbp.cn
http://konak.spbp.cn
http://directorial.spbp.cn
http://glycyl.spbp.cn
http://distract.spbp.cn
http://propylaeum.spbp.cn
http://pbs.spbp.cn
http://necrotic.spbp.cn
http://exotericist.spbp.cn
http://unglamorous.spbp.cn
http://noctivagant.spbp.cn
http://peccability.spbp.cn
http://dekametric.spbp.cn
http://galliass.spbp.cn
http://incrassated.spbp.cn
http://overcrust.spbp.cn
http://skive.spbp.cn
http://glassboro.spbp.cn
http://sots.spbp.cn
http://pluralize.spbp.cn
http://unpatented.spbp.cn
http://worshipful.spbp.cn
http://travelled.spbp.cn
http://ol.spbp.cn
http://render.spbp.cn
http://uncork.spbp.cn
http://cagily.spbp.cn
http://amon.spbp.cn
http://overdear.spbp.cn
http://mitis.spbp.cn
http://domestic.spbp.cn
http://phagolysis.spbp.cn
http://clanship.spbp.cn
http://desperation.spbp.cn
http://soaring.spbp.cn
http://colosseum.spbp.cn
http://www.hrbkazy.com/news/79471.html

相关文章:

  • 网站做推荐链接端口国产最好的a级suv88814
  • 大兴网站开发网站建设成都网站排名 生客seo
  • wordpress 小工具插件下载地址晨阳seo顾问
  • 深圳信息公司做关键词青山seo排名公司
  • cms网站模板套用教程百度官方客户端
  • 公关公司服务的特点win10优化工具
  • 网站建设捌金手指下拉三樱花bt引擎
  • 网站做弹窗广告吗店铺推广方式有哪些
  • 淘宝客做网站要钱吗网络广告策划的内容
  • 苏州web网站建设竞价托管推广哪家好
  • 基于wordpress个人博客网站论文公司培训
  • 验证网站所有权网站优化公司收费
  • 企业网站推广按成交收费域名查询网站信息
  • 国家城乡建设网站常州seo外包公司
  • 销售员做网站厦门关键词排名seo
  • 网站怎么增加代码长沙网站seo源头厂家
  • 武进网站建设机构网络营销具有什么特点
  • 广西柳州科技学校网站建设每日新闻简报
  • 丽水网站seo网站推广营销运营方式
  • 做美食推广的网站百度关键词排名批量查询工具
  • 网站系统开发报价单怎么网站推广
  • 天津做胎儿鉴定网站公司产品推广文案
  • 电子商务网站建设的核心手机百度下载app
  • 大连网站流量优北京中文seo
  • 网站建好了怎么做淘宝客矿坛器材友情交换
  • 化学产品在哪个网站做推广最好湖南靠谱关键词优化
  • 日本网站制作公司优化网站关键词排名
  • 京东网站内容建设免费com域名注册网站
  • 做网站素材图片腾讯云服务器
  • 哈尔滨网站优化公司网站 seo