51nod-2510-顺子

题目: 小b有n张牌。 现在她想把牌分组,使得每组都是长度为W的顺子,即由连续W个数组成。 请问小b能做到吗? ...

October 14, 2019 · 1 min · 159 words · eonh1u

51nod-2500-后面第一个大于

题目: 小b有一个长度为n的序列t,现在她对于每个i,求最小的正数j满足𝑖+𝑗≤𝑛且𝑡𝑖+𝑗>𝑡𝑖,输出j,如果不存在这样的j,则输出0。 样例解释: 对于i=1,𝑡2>𝑡1,所以最小的j=1; 对于i=7,不存在这样的j,所以输出0。 ...

October 14, 2019 · 1 min · 116 words · eonh1u

51nod-2499-不降的数字

题目: 小b有一个非负整数N,她想请你找出 ≤𝑁 的最大整数x,满足x各个位数上的数字是不降的。也就是说,设x的十进制表示为 𝑎1,𝑎2,…,𝑎𝑚,则对于任意 1≤𝑖<𝑚,𝑎𝑖≤𝑎𝑖+1。 ...

October 14, 2019 · 1 min · 168 words · eonh1u

51nod-2494-最长配对

题目: 小b有一个01序列,她想找到一个最长的区间使得这个区间的01能两两配对,即0的个数和1的个数相等。求最长区间的长度。 输入 第一行一个正整数n,表示数组长度,其中0<n≤50000; 第二行n个0或1,以空格隔开。 输出 输出一个数,表示最长区间的长度 ...

October 14, 2019 · 1 min · 113 words · eonh1u

51nod-2484-小b和排序

题目: 小b有两个长度都为n的序列A,B。 现在她需要选择一些i,然后交换A[i]和B[i],使得A和B都变成严格递增的序列。 你能帮小b求出最少交换次数吗? 输入保证有解。 ...

October 14, 2019 · 1 min · 150 words · eonh1u

51nod-2462-铺设道路

题目: 春春是一名道路工程师,负责铺设一条长度为 n 的道路。 铺设道路的主要工作是填平下陷的地表。整段道路可以看作是 n 块首尾相连的区域,一开始,第 i 块区域下陷的深度为 𝑑𝑖 。 春春每天可以选择一段连续区间[L,R] ,填充这段区间中的每块区域,让其下陷深度减少 1。在选择区间时,需要保证,区间内的每块区域在填充前下陷深度均不为 0 。 春春希望你能帮他设计一种方案,可以在最短的时间内将整段道路的下陷深度都变为 0 。 ...

October 12, 2019 · 1 min · 83 words · eonh1u

51nod-1925-进制转换

题目 有一个变进制系统从低位到高位的权值依次是 1,3,7,15,31,… 。即第i(i>=0)位的权值是 2𝑖+1−1 。每一位数字是0,1,或者2。现在有一个十进制的数字n,想要把它转换成变进制系统下面的表示。由于有2的存在,这种转换可能会有多种可能,现在规定2只能作为最低非0位出现,这种情况下,表示就唯一了。 比如44可能用15+15+7+7(2200)来表示,但是这样前面那个2就没有作为最低非0位出现,所以不符合要求,正确的转换是10120。 ...

October 12, 2019 · 1 min · 159 words · eonh1u

51nod-1506-最小字典序

题目: 给出一个字符串S,你需要从S中挑选一对字符进行一次交换(不可以不交换!!!!!!),并让得到的新字符字典序最小! 例如:S = “abacc”, 如果交换字符1(a)和4(c),得到字符"cbaac"。 如果交换字符2(a)和3(b),得到字符"aabcc"。 其中:“aabcc"的字典序小于"cbaac”。并且"aabcc"是所有交换方法中,字典序最小的。 例如:S = “aaab”, 则交换1和2,交换1和3,得到的字符都是 “aaab”,并且 “aaab"是所有交换方法中,字典序最小的。 输出这个字典序最小的字符。 ...

October 12, 2019 · 1 min · 126 words · eonh1u

cf-591-div2

A: CME 题目: Let’s denote correct match equation (we will denote it as CME) an equation 𝑎+𝑏=𝑐 there all integers 𝑎, 𝑏 and 𝑐 are greater than zero. For example, equations 2+2=4 (||+||=||||) and 1+2=3 (|+||=|||) are CME but equations 1+2=4 (|+||=||||), 2+2=3 (||+||=|||), and 0+1=1 (+|=|) are not. Now, you have 𝑛 matches. You want to assemble a CME using all your matches. Unfortunately, it is possible that you can’t assemble the CME using all matches. But you can buy some extra matches and then assemble CME! ...

October 7, 2019 · 9 min · 1852 words · eonh1u

ucas 2小题

A: Given an array of size n, find the majority element. The majority element is the element that appears more than b n c times.You may assume that the array is non-empty and the majority 2 element always exist in the array. INPUT: Line 1: the length of array. Line 2: the all elements in array and split by spaces OUTPUT: Line 1: A single integer that is the majority element. ...

October 6, 2019 · 2 min · 311 words · eonh1u