![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
牛客网机试练习
啄鸟木
这个作者很懒,什么都没留下…
展开
-
牛客网KY115-后缀子串排序
题目描述对于一个字符串,将其后缀子串进行排序,例如grain 其子串有: grain rain ain in n 然后对各子串按字典顺序排序,即: ain,grain,in,n,rain输入描述:每个案例为一行字符串。输出描述:将子串排序输出输入grain输出aingraininnrain代码#include<iostream>#include<string>#include<algorithm>using namespace st原创 2020-08-20 22:04:08 · 240 阅读 · 0 评论 -
牛客网KY72-digitalroots
题目描述The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two or more digits, those digits are summed and the pro原创 2020-08-19 22:20:10 · 128 阅读 · 1 评论 -
牛客网KY59-神奇的口袋
题目描述有一个神奇的口袋,总的容积是40,用这个口袋可以变出一些物品,这些物品的总体积必须是40。John现在有n个想要得到的物品,每个物品的体积分别是a1,a2……an。John可以从这些物品中选择一些,如果选出的物体的总体积是40,那么利用这个神奇的口袋,John就可以得到这些物品。现在的问题是,John有多少种不同的选择物品的方式。输入描述:输入的第一行是正整数n (1 <= n <= 20),表示不同的物品的数目。接下来的n行,每行有一个1到40之间的正整数,分别给出a1,a2……原创 2020-08-19 21:57:51 · 169 阅读 · 1 评论 -
牛客网-KY45-skew数
题目描述在 skew binary 表示中,第 k 位的值 x[k] 表示 x[k]×(2^(k+1)-1)。每个位上的可能数字是 0 或 1,最后面一个非零位可以是 2,例如,10120(skew) = 1×(2^5-1) + 0×(2^4-1) + 1×(2^3-1) + 2×(2^2-1) + 0×(2^1-1) = 31 + 0 + 7 + 6 + 0 = 44。前十个 skew 数是 0、1、2、10、11、12、20、100、101、以及 102。输入描述:输入包括多组数据,每组数据包含一原创 2020-08-18 22:22:11 · 100 阅读 · 0 评论 -
牛客网机试-KY259-编排字符串
题目描述请输入字符串,最多输入4 个字符串,要求后输入的字符串排在前面,例如输入:EricZ输出:1=EricZ输入:David输出:1=David 2=EricZ输入:Peter输出:1=Peter 2=David 3=EricZ输入:Alan输出:1=Alan 2=Peter 3=David 4=EricZ输入:Jane输出:1=Jane 2=Alan 3=Peter 4=David输入描述:第一行为字符串个数m,接下来m行每行一个字符床,m不超过100,原创 2020-08-18 21:01:21 · 135 阅读 · 0 评论 -
牛客网机试题-KY238-problemE
题目描述请写一个程序,判断给定表达式中的括号是否匹配,表达式中的合法括号为”(“, “)”, “[", "]“, “{“, ”}”,这三个括号可以按照任意的次序嵌套使用。输入描述:有多个表达式,输入数据的第一行是表达式的数目,每个表达式占一行。输出描述:对每个表达式,若其中的括号是匹配的,则输出”yes”,否则输出”no”。输入4[(d+f)*{}][(2+3))()}[4(6]7)9输出yesnonono代码#include<iostream>#inc原创 2020-08-18 20:16:44 · 152 阅读 · 0 评论 -
牛客网机试题-KY25-剩下的树
题目描述有一个长度为整数L(1<=L<=10000)的马路,可以想象成数轴上长度为L的一个线段,起点是坐标原点,在每个整数坐标点有一棵树,即在0,1,2,…,L共L+1个位置上有L+1棵树。 现在要移走一些树,移走的树的区间用一对数字表示,如 100 200表示移走从100到200之间(包括端点)所有的树。 可能有M(1<=M<=100)个区间,区间之间可能有重叠。现在要求移走所有区间的树之后剩下的树的个数。输入描述:两个整数L(1<=L<=1000原创 2020-08-15 21:15:53 · 191 阅读 · 0 评论 -
牛客网机试KY242-围圈报数
题目描述N 个人围成一圈顺序编号,从1 号开始按1、2、3 顺序报数,报3 者退出圈外,其余的人再从1、2、3 开始报数,报3 的人再退出圈外,依次类推。请按退出顺序输出每个退出人的原序号。要求使用环行链表编程。输入描述:输入第一行为整数m表示有m组测试数据,接下来m行每行一个整数N,N不超过50。输出描述:输出m行,每行表示题目所求,用空格隔开。输入14输出3 2 4 1代码#include<iostream>using namespace std;int原创 2020-08-15 19:50:07 · 177 阅读 · 0 评论 -
牛客网机试练习KY121-sharing
题目描述To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example, “loading” and “being” are stored as showed in Figu原创 2020-08-07 21:50:24 · 149 阅读 · 0 评论 -
牛客网KY102-计算表达式
题目描述对于一个不存在括号的表达式进行计算输入描述:存在多种数据,每组数据一行,表达式不存在空格输出描述:输出结果输入6/2+3+3*4输出18我的错误代码#include<iostream>using namespace std;int main(){ int num[1000]; int top1 = -1; char oper[1000]; //int temp1[1000]; //char temp2[1000]; int top2 = -1原创 2020-08-05 22:48:20 · 151 阅读 · 0 评论 -
牛客网KY109-zero-complexity transposition
题目描述You are given a sequence of integer numbers. Zero-complexity transposition of the sequence is the reverse of this sequence. Your task is to write a program that prints zero-complexity transposition of the given sequence.输入描述:For each case, the first原创 2020-08-05 21:14:50 · 216 阅读 · 0 评论 -
牛客网KY-52位操作练习
题目描述给出两个不大于65535的非负整数,判断其中一个的16位二进制表示形式,是否能由另一个的16位二进制表示形式经过循环左移若干位而得到。 循环左移和普通左移的区别在于:最左边的那一位经过循环左移一位后就会被移到最右边去。比如: 1011 0000 0000 0001 经过循环左移一位后,变成 0110 0000 0000 0011, 若是循环左移2位,则变成 1100 0000 0000 0110输入描述:每行有两个不大于65535的非负整数输出描述:对于每一行的两个整数,输出一行,内容为Y原创 2020-08-03 23:07:07 · 161 阅读 · 0 评论