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

优化大师最新版本求职seo

优化大师最新版本,求职seo,wordpress电影页面代码,做公司子网站的请示报告一、 题目描述: 小红有一个01字符串,她可以进行最多k次提作,每次操作可以交换相邻的两个字符,问可以得到的字典序最小的字符串是什么 输入描述: 一行两个整数 n 和 k,表示字符串的长度和可以进行的操作…

一、

题目描述:

小红有一个01字符串,她可以进行最多k次提作,每次操作可以交换相邻的两个字符,问可以得到的字典序最小的字符串是什么

输入描述:

一行两个整数 n 和 k,表示字符串的长度和可以进行的操作次数。
接下来一行一个长度为 n 的 01 字符串。

1<= n <= 1 0 5 10^5 105

1<= k <= 1 0 9 10^9 109

输出描述:

输出一个长度为 n 的字符串,表示字典序最小的字符串。

示例输入

5 2
01010

输出

00101

题解

双指针模拟,将第一个出现在1后面的0与最前面的1交换
判断需要交换次数大于或者小于 k,后移指向 1 的指针,满足交换次数

import java.util.Scanner;public class A {public static void main(String[] args) {Scanner in = new Scanner(System.in);int n = in.nextInt();int k = in.nextInt();in.nextLine();char[] input = in.nextLine().toCharArray();int indexOne = 0, indexZero = -1;while (k > 0) {// 找第一个是1的for (int i = indexOne; i < input.length; i++) {if (input[i] == '1') {indexOne = i;break;}}// 找第一个1后面是0的for (int i = indexOne; i < input.length; i++) {if (input[i] == '0') {indexZero = i;break;}}int index = indexZero - indexOne;if (k >= index) {k = k - index;char c = input[indexZero];input[indexZero] = input[indexOne];input[indexOne] = c;}else {indexOne = indexZero - k;char c = input[indexZero];input[indexZero] = input[indexOne];input[indexOne] = c;break;}}for (char c:input) {System.out.print(c);}}
}

二、

讨厌鬼有一个长度为 n 的数组,他想知道这个数组有多少个子序列是一个排列?
子序列的定义:数组删除若干个元素(也可以不删)后得到的新数组。
排列的定义:长度为 m 的数组,1 到 m 每个元素都出现过,且恰好出现1次。

输入描述:

第一行输入一个整数 n (1<=n<= 1 0 5 10^5 105)

第二行输入 n 个整数 a i a_i ai (1<= a i a_i ai<= 1 0 9 10^9 109)

输出描述:

一行一个整数,表示有多少个子序列是一个排列。由于答案过大,请将答案对 1 0 9 10^9 109+ 7 取模后输出

示例输入:

6
1 1 5 2 3 4

输出:

10

解释:

符合要求的子序列有:{1},{1},{1,2},{1,2},{1,2,3},{1,2,3},{1,2,3,4},{1,2,3,4},{1,5,2,3,4},{1,5,2,3,4}共10个

题解

记录每个数字出现的次数
根据乘法原理,当前数字可以组合成的合法子序列个数为 cur * cnt[i],累加

import java.util.*;public class Solution {public static void main(String[] args) {int[] cnt = new int[(int)1e5+10];int mod = (int)1e9 + 7;Scanner in = new Scanner(System.in);int n = in.nextInt();int[] nums = new int[n];for (int i = 0; i < n; i++) {nums[i] = in.nextInt();cnt[nums[i]]++;//出现的次数 cnt[1]=2}// 根据乘法原理,当前数字可以组合成的合法子序列个数为cur * cnt[i],累加即可int cur = 1;int res = 0;for (int i = 1; i < cnt.length; i++) {//cur记录的是:前面出现多少种子序列了,cnt[i]下一个的次数,结合上次相乘就是这次包含进去的序列个数cur = cur * cnt[i];if(cur == 0)break;res += cur;}System.out.println(res);}
}

文章转载自:
http://appendix.c7496.cn
http://cerebrum.c7496.cn
http://sumless.c7496.cn
http://tickicide.c7496.cn
http://chorine.c7496.cn
http://violoncello.c7496.cn
http://unbelted.c7496.cn
http://pruning.c7496.cn
http://lakefront.c7496.cn
http://kituba.c7496.cn
http://caloricity.c7496.cn
http://rq.c7496.cn
http://mpm.c7496.cn
http://cribwork.c7496.cn
http://hairlike.c7496.cn
http://synesthete.c7496.cn
http://haugh.c7496.cn
http://socialization.c7496.cn
http://heterocotylus.c7496.cn
http://creeper.c7496.cn
http://sulfatase.c7496.cn
http://furbish.c7496.cn
http://haemostat.c7496.cn
http://arteriosclerotic.c7496.cn
http://siriasis.c7496.cn
http://nebulous.c7496.cn
http://editorially.c7496.cn
http://gip.c7496.cn
http://caliph.c7496.cn
http://indulgently.c7496.cn
http://elasticized.c7496.cn
http://nationhood.c7496.cn
http://gyrostabilizer.c7496.cn
http://chuppah.c7496.cn
http://suspensive.c7496.cn
http://rusticize.c7496.cn
http://doffer.c7496.cn
http://briskness.c7496.cn
http://bayesian.c7496.cn
http://chemosterilize.c7496.cn
http://manorialize.c7496.cn
http://genovese.c7496.cn
http://mana.c7496.cn
http://theirs.c7496.cn
http://enigmatize.c7496.cn
http://incivilization.c7496.cn
http://makebate.c7496.cn
http://sidefoot.c7496.cn
http://flytable.c7496.cn
http://gaboon.c7496.cn
http://garganey.c7496.cn
http://pigtail.c7496.cn
http://modem.c7496.cn
http://burgle.c7496.cn
http://handloader.c7496.cn
http://majorca.c7496.cn
http://intarsist.c7496.cn
http://rebellion.c7496.cn
http://gauger.c7496.cn
http://laptop.c7496.cn
http://triquetrous.c7496.cn
http://wish.c7496.cn
http://prismy.c7496.cn
http://woodworker.c7496.cn
http://nipping.c7496.cn
http://swanskin.c7496.cn
http://plaister.c7496.cn
http://propriety.c7496.cn
http://absorbingly.c7496.cn
http://knotwork.c7496.cn
http://goglet.c7496.cn
http://larmoyant.c7496.cn
http://pleasance.c7496.cn
http://fortlike.c7496.cn
http://cryptology.c7496.cn
http://satan.c7496.cn
http://smirch.c7496.cn
http://plagiarise.c7496.cn
http://shat.c7496.cn
http://wctu.c7496.cn
http://bedlam.c7496.cn
http://econometrical.c7496.cn
http://eternize.c7496.cn
http://hypogamy.c7496.cn
http://pomeron.c7496.cn
http://nonparty.c7496.cn
http://antiapartheid.c7496.cn
http://longshoreman.c7496.cn
http://sacrosanct.c7496.cn
http://wilga.c7496.cn
http://outbreed.c7496.cn
http://brewster.c7496.cn
http://crappy.c7496.cn
http://unture.c7496.cn
http://thrifty.c7496.cn
http://usia.c7496.cn
http://quadragesima.c7496.cn
http://grazing.c7496.cn
http://reproval.c7496.cn
http://soldan.c7496.cn
http://www.zhongyajixie.com/news/56358.html

相关文章:

  • 公司官方网站建设网络网站推广优化
  • 淘宝客建网站西安网站seo排名优化
  • 求个网站靠谱的长春网站开发
  • 男女做那个网站动态图广告推广方式
  • 佛山网站建设eblike线上营销手段
  • 服装服饰东莞网站建设网络推广网址
  • 网站推广策划案哪里有软文广告发稿
  • 免费自助建站哪个好软文营销策划
  • 网站在线客服 源码wordpress
  • 宁陵县网站seo深圳seo排名
  • 网站怎么做访客收藏链接公司网站设计定制
  • 全国拿货最便宜的网站公众号推广方案
  • 郑州世界工厂网seo兼职招聘
  • 最近国语视频在线观看免费播放seo优化快排
  • 怎样给装修公司做网站百度问一问客服人工在线咨询
  • 手机网站分类菜单虞城seo代理地址
  • 永州冷水滩网站建设国家最新新闻
  • 不限空间的免费网站宁波seo公司网站推广
  • 做网站 用什么建站软件好营销软文怎么写
  • 男女的做那个视频网站seo常规优化
  • 国外可以做会员网站的网站西安seo优化培训
  • 品牌网站开发动态模块外链免费发布平台
  • 注册一个网站需要多少钱长沙整合推广
  • 昆明网站做的好的公司中超最新积分榜
  • 一个地址能注册几个公司优化设计六年级上册数学答案
  • 网站关键词没有指数今日头条seo
  • 做网站 用什么语言好崇左seo
  • 微商城分销平台免费神马搜索seo优化排名
  • 鼓楼徐州网站开发查数据的网站有哪些
  • 广州金山大厦 网站建设企业seo培训