2023年福建省第三届大学生程序设计竞赛题目
- 格式:doc
- 大小:116.00 KB
- 文档页数:20
2023杭电多校第三场题解摘要:1.2023 杭电多校第三场题解概述2.第一题:编写一个程序,输出从1 到n 的数字3.第二题:编写一个程序,实现斐波那契数列的求解4.第三题:编写一个程序,判断一个字符串是否为回文字符串5.总结和建议正文:【2023 杭电多校第三场题解概述】2023 年杭电多校第三场考试已经结束,本次考试共设置了三道题目,分别涉及到编程基础、数列求解和字符串处理等方面的知识。
本文将为您详细解析这三道题目的解题思路和方法。
【第一题:编写一个程序,输出从1 到n 的数字】这道题目主要考察了编程基础,要求编写一个程序,输出从1 到n 的数字。
解决这个问题有多种方法,可以使用循环语句(如for 循环、while 循环)或者使用数学方法(如等差数列求和公式)。
以下是一个简单的Python 实现:```pythonfor i in range(1, n+1):print(i)```【第二题:编写一个程序,实现斐波那契数列的求解】斐波那契数列是一个经典的数列问题,要求编写一个程序,实现斐波那契数列的求解。
斐波那契数列的定义为:F(0)=0,F(1)=1,F(n)=F(n-1)+F(n-2)。
解决这个问题有多种方法,可以使用递归、循环或者矩阵求幂等方法。
以下是一个简单的Python 实现:```pythondef fibonacci(n):if n == 0:return 0elif n == 1:return 1else:return fibonacci(n-1) + fibonacci(n-2)print(fibonacci(n))```【第三题:编写一个程序,判断一个字符串是否为回文字符串】回文字符串是指正序和倒序都相同的字符串,如“abcdcba”。
这道题目要求编写一个程序,判断一个字符串是否为回文字符串。
解决这个问题有多种方法,可以使用双指针法、哈希表或者直接比较字符串等方法。
以下是一个简单的Python 实现:```pythondef is_palindrome(s):s = s.lower()left, right = 0, len(s) - 1while left < right:if s[left]!= s[right]:return Falseleft += 1right -= 1return Trueprint(is_palindrome("abcdcba"))```【总结和建议】本次考试的三道题目涉及到了编程基础、数列求解和字符串处理等方面的知识。
2023年电赛h题思路2023年电赛H题是一道涉及电路设计和编程的题目,要求参赛选手设计一个能够检测并显示电压、电流、功率和电阻的测量仪器。
以下是我对这道题目的思路和解决方案。
首先,我们需要设计一个电路,可以将输入的电压、电流和功率转化为可以读取的信号。
为了实现这一目标,我们可以使用电阻和电流表来测量电流,电压表来测量电压,电能表来测量功率。
电阻可以通过电压和电流的比值来计算。
为了确保电路的准确性和稳定性,我们可以使用放大电路和滤波电路来处理信号,以获得更准确的测量结果。
其次,我们需要编程实现测量仪器的功能。
我们可以选择使用Arduino或者树莓派等单片机来编写程序。
首先,我们需要编写代码来读取电路中的电压、电流和功率值。
可以使用模拟输入引脚来读取电压和电流,使用数字输入引脚来读取功率。
接着,我们可以编写代码来计算电阻值,可以使用电压和电流的比值来计算。
最后,我们可以编写代码来显示测量结果,可以使用LCD显示屏或者数码管来显示电压、电流、功率和电阻的数值。
除了基本功能外,我们还可以考虑增加一些附加功能来提升测量仪器的实用性和便利性。
例如,可以添加一个按钮或者旋钮来切换测量模式,可以选择测量电压、电流、功率或者电阻。
可以添加存储功能,将测量结果保存到内存中或者SD卡中,方便后续的数据处理和分析。
可以添加通信功能,通过串口或者无线模块将测量结果发送到计算机或者手机上,实现远程监控和数据传输。
在设计和编程过程中,我们需要注意以下几点。
首先,电路设计需要考虑到电压和电流的范围,选择合适的电阻和放大电路,以确保测量结果的准确性和稳定性。
其次,编程需要考虑到数据的采样和处理,选择合适的采样频率和数据处理算法,以提高测量精度和响应速度。
最后,我们需要进行严格的测试和验证,确保测量仪器的功能和性能达到要求。
综上所述,2023年电赛H题是一道涉及电路设计和编程的题目,要求设计一个能够检测并显示电压、电流、功率和电阻的测量仪器。
第三届郑州⼤学程序设计竞赛题⽬第三届郑州⼤学程序设计竞赛(2009)【试题⼀】来源: ZDM001句⼦缩写Dr. Kong的四岁⼥⼉Mary刚学会认识英⽂字母。
神奇的是,虽然她还不认识⼀个单词,但你给她⼀个⼩写字母,她马上能写出对应的⼤写字母。
Dr. Kong决定考考⼥⼉Mary,于是布置了⼀个作业,给她若⼲个语句,每个语句由若⼲个单词组成,单词之间严格由⼀个空格隔开,句⼦最后以. 结束。
Mary的任务是把每个句⼦进⾏缩写,即每个句⼦是由各单词的⾸字母构成,缩写⽤⼤写字母表⽰。
你认为Mary能完成任务吗?【标准输⼊】第⼀⾏:N 表⽰有N个句⼦接下来有N⾏,每⾏有⼀个由若⼲单词构成的语句,并以. 结束。
【标准输出】输出有N⾏,每⾏是⼀个对应句⼦的缩写【约束条件】1≤N≤ 10每个单词都是由⼩写字母组成,单词长度不超过10。
句⼦的总长度不超过80。
【样例】【试题⼆】来源: BLLA +B +C 问题热⾝赛的时候,⼤家完成了A+B 问题,jsxgblcxp觉得,如果在正式⽐赛的时候还继续这样问题的话,会显得很⽆趣的。
所以,他决定要出⼀个更难的题⽬。
来增加⼀下⽐赛的趣味。
【标准输⼊】第⼀⾏:N 表⽰有N组数据接下来有N⾏,每组有4个整数:R A B C分别表⽰R进制和你需要求和的三个数字。
【标准输出】每组数据输出⼀⾏,即(A+B+C)R【约束条件】1≤N≤6A B C为正整数,每个正整数不超过50位【样例】如果你真的不知道该怎么写。
那么,请⾯对你⾯前的屏幕这样祈祷:“啊~万能的图灵啊~为什么会有这么长的数字和这么多的进制啊难道世界只有⼀个⼆进制不好么”贪婪的神⽜在上古时代,有⼀位神⽜叫Cheapwine,⼿持⼀把The depression of the Frost⼑( 就是死骑那把霜之哀伤,估计是神⽜秒杀掉DK之后⽤来削苹果的,然后看到这个把⼑挺好看的,于是就留在了⾝边 )。
有⼀天,Cheapwine在郊区ZZU西门外抓兔⼦,今天Cheapwine的rp很⾼,抓到了好多兔⼦。
精品文档名目2单选题_________________________________________8多选题_________________________________________推断题_________________________________________1215填空题_________________________________________精品文档单选题的核心部分。
)是.NET平台是一个新的开发框架,( .NET Framework。
表 )2.Access数据库最基础的对象是(控件的功能(记录导航)。
3.BindingNavigator)属性。
控件中的(DataSource4.要连接数据库,需要设置BindingSource)语言演化而来。
和C++5.C#语言从(C对象 )的语言。
6.C#是一种面向(7.C#语言取消了( 指针 )语法。
)方法更新数据库。
对象的( Update中通过DataAdapter)方法填充记录集。
对象的( Fill中记录集的显示是通过DataAdapter控件中显示的字段名称,应修改( Columns)属性。
要设置DataGridView10.中执行一个存储过程时,假如要设置输出参数则必须同时设置参数的方向和(类型),必要时还要设在11.置参数尺寸。
)对象保存当前数据集。
中通过( DataSet12.)。
13.在下面循环语句中循环体执行的次数为(n/2+1for(int i=0; i<n; i++)if(i>n/2) break;”循环次数为(7)次){ }循环语句“for14.(int i=30;i>=10;i-=3下面程序段的运行后,n的值为(6)。
15.n=1;for(i=1;i<=3;i++)n=n*i;)的值为(55下面程序段执行后,sum16.int i,sum;for(i=1,sum=0;i<=10;i++)sum+=i;中产生二义性,C语言规定else子句总是与(其之前最近的,同一复合语为了幸免在嵌套的条件语句if-else17.)配对。
2023年计算机科学类编程题目及解析110题题目1题目描述:编写一个函数,判断一个字符串是否是回文字符串。
解析:回文字符串是指正序和逆序读都是一样的字符串。
我们可以通过比较字符串与其反转字符串是否相等来判断是否为回文字符串。
def is_palindrome(string):return string == string[::-1]题目2题目描述:编写一个函数,找出一个列表中的最大数和最小数。
解析:我们可以使用Python内置的`min`和`max`函数来找出列表中的最大和最小元素。
def find_max_min(lst):return max(lst), min(lst)题目3题目描述:给定一个字符串,统计每个字符在字符串中出现的次数,并返回出现次数最多的字符。
解析:我们可以使用Python中的`collections`模块的`Counter`类来统计字符出现的次数。
然后,我们可以使用`max`函数找出出现次数最多的字符。
from collections import Countercounter = Counter(string)return max(counter, key=counter.get)...题目110题目描述:编写一个函数,计算斐波那契数列的第n个数。
解析:斐波那契数列是指从0和1开始,后面的每一项都是前面两项的和。
我们可以使用递归或循环的方式来计算斐波那契数列的第n个数。
def fibonacci(n):if n <= 0:return "Invalid input"elif n == 1 or n == 2:return 1else:a, b = 1, 1for _ in range(3, n + 1):a, b = b, a + breturn b以上是2023年计算机科学类编程题目及解析的部分内容,总共包含110道题目及解析。
2023国赛c题解析摘要:1.题目概述2.解题思路3.具体步骤4.注意事项正文:国赛C题是每年竞赛中备受关注的一道题目,因为它既考验了选手的编程能力,又考察了选手对算法和数据结构的理解。
下面我们将对2023年国赛C 题进行详细解析,帮助大家更好地掌握这道题目。
一、题目概述2023年国赛C题要求选手编写一个程序,解决一个特定的问题。
题目描述如下:【题目描述】……二、解题思路在分析题目后,我们可以发现问题的关键在于如何处理输入的数据以及如何优化算法的效率。
为此,我们需要运用以下解题思路:1.数据预处理:首先,对输入的数据进行预处理,提取有用的信息。
2.建立数学模型:根据题目描述,建立相应的数学模型,将问题转化为数学求解。
3.算法设计:针对数学模型,设计相应的算法,如动态规划、贪心算法等。
4.程序实现:将算法实现为程序代码,并进行调试优化。
三、具体步骤1.步骤一:阅读题目,理解题意。
2.步骤二:分析题目,提炼关键信息。
3.步骤三:设计算法,构建数学模型。
4.步骤四:编写程序,实现算法。
5.步骤五:调试优化,提高程序性能。
四、注意事项1.仔细阅读题目,勿遗漏关键信息。
2.掌握常见算法和数据结构,灵活运用。
3.代码风格规范,注释清晰,便于理解。
4.注意时间复杂度和空间复杂度,尽量优化程序性能。
5.预留足够的时间进行调试和优化,避免因时间紧迫导致失误。
通过以上分析,我们相信大家对2023年国赛C题有了更深入的了解。
在实际比赛中,希望大家能够灵活运用解题思路和技巧,顺利完成这道题目,取得好成绩。
cupt2023题目解析
每年,学术界以及大学生们都会热切期待CUPT(College University Programming Tournament)。
CUPT2023已经进入决赛季,有许多题目等待着那些喜欢挑战自己的人们,值得一提的是,今年的题目难度和以往丝毫不逊,前所未有地增加了一定的挑战。
CUPT2023包含了多种类型的题目,它们分别是算法题,数学模型题,程序设计题,计算机技术题和逻辑题。
比赛要求学生分别回答每种题型的实际题目。
如果题目很难,学生们可以通过分析题目,注意比赛规则,阅读文献和练习而获得一定的优势。
首先,参赛者应该对题目的条件和限制有一个清晰的认识,对题目的要求有一个明确的把握,在解题之前,要明确题目的主旨,找出解题思路。
其次,参赛者需要花费必要的时间阅读文献,有助于他们更好地理解题目的背景,以及与题目有关的一些概念和理论。
参赛者可以查阅一些书籍,杂志和学术文章,以便对自己解题时所面对的相关知识有全面的了解。
最后,参赛者可以利用计算机实现其想法,具体来说,就是用计算机编写代码,根据要求编写程序,以此来解决题目,按照要求输出答案所需要的结果。
为了大家能够更好地把握题目,在进行解题操作前,参赛者有必要重新浏览题目,并细致地研究题目,因为重新浏览会帮助参赛者尽快完成解题。
总之,参加CUPT2023的参赛者需要具备良好的思维品质,内敛的专业技能以及一定的文献知识,才能在比赛中获得好的成绩。
只有提升自己的能力,训练自己的思维,把题目分析的足够深入的参赛者,才能在CUPT2023中取得好成绩。
cupt2023题目解析CUPT2023是中国大学程序设计竞赛(CUPT)的一次大赛,也是目前最具标志性的中国大学程序设计竞赛之一。
CUPT2023的题目完成时间将从2023年7月10日持续至2023年7月14日。
在本次竞赛中,共设置了十项题目,包括算法题、编程题、数据结构题、智能算法题、图形学题、数据库题等,其中算法题和编程题最为常见。
算法题算法题是CUPT2023竞赛中最多的一类题目。
它们涉及到许多领域,如搜索算法、排序算法、数据结构算法等。
这类题目主要评测参赛者在算法理论知识及其实际应用方面的综合能力。
举例来说,一道算法题可能需要参赛者设计一个排序算法,并编写一段代码来实现,还需要考虑其它因素,如算法的时间复杂度、空间复杂度等。
编程题编程题也是CUPT2023竞赛中一类题目,主要考察参赛者对编程语言的熟练程度和代码实现能力。
这类题目通常需要参赛者使用一种特定的编程语言(如C++、Java)来完成一个具体的任务,例如编写一个游戏、实现一个计算器等等。
数据结构题数据结构题是CUPT2023竞赛中另一类题目,主要要求参赛者对数据结构的基础知识有所了解,并能够将其实际应用到算法题中。
这类题目可能需要参赛者构建或实现一个特定的数据结构,如堆、二叉搜索树、图等,并使用这些数据结构来完成相应的算法操作,以得到期望的结果。
智能算法题智能算法题是CUPT2023竞赛中最新添加的一类题目,它们涉及到机器学习等技术,主要考察参赛者对智能算法的运用能力。
这类题目可能需要参赛者使用某种特定的智能算法(如神经网络算法)来完成一项具体的任务,例如解决一个分类问题、解决一个回归问题等。
图形学题图形学题是CUPT2023竞赛中最具挑战性的一类题目,它们涉及到计算机图形学、计算机视觉等技术,主要考察参赛者在图形学领域的实践能力。
这类题目可能要求参赛者设计一个图形处理算法,实现某个图形处理任务,例如图像分析、视频分析、三维重建等。
Problem A Solve equationAccept: 111 Submit: 229Time Limit: 1000 mSec Memory Limit : 32768 KB Problem DescriptionYou are given two positive integers A and B in Base C. For the equation:A=k*B+dWe know there always existing many non-negative pairs (k, d) that satisfy the equation above. Now in this problem, we want to maximize k.For example, A="123" and B="100", C=10. So both A and B are in Base 10. Then we have:(1) A=0*B+123(2) A=1*B+23As we want to maximize k, we finally get one solution: (1, 23)The range of C is between 2 and 16, and we use 'a', 'b', 'c', 'd', 'e', 'f' to represent 10, 11, 12, 13, 14, 15, respectively.InputThe first line of the input contains an integer T (T≤10), indicating the number of test cases.Then T cases, for any case, only 3 positive integers A, B and C (2≤C≤16) in a single line. You can assume that in Base 10, both A and B is less than 2^31.OutputFor each test case, output the solution “(k,d)” to the equation in Base 10. Sample Input32bc 33f 16123 100 101 1 2Sample Output(0,700)(1,23)(1,0)Problem B Bin & Jing in wonderlandAccept: 4 Submit: 28Time Limit: 1000 mSec Memory Limit : 32768 KB Problem DescriptionBin has a dream that he and Jing are both in a wonderland full of beautiful gifts. Bin wants to choose some gifts for Jing to get in her good graces.There are N different gifts in the wonderland, with ID from 1 to N, and all kinds of these gifts have infinite duplicates. Each time, Bin shouts loudly, “I love Jing”, and then the wonder land random drop a gift in front of Bin. The dropping probability for gift i (1≤i≤N) is P(i). Of cause, P(1)+P(2)+…+P(N)=1. Bin finds that the gifts with the higher ID are better. Bin shouts k times and selects r best gifts finally.That is, firstly Bin gets k gifts, then sorts all these gifts according to their ID, and picks up the largest r gifts at last. Now, if given the final list of the r largest gifts, can you help Bin find out the probability of the list?InputThe first line of the input contains an integer T (T≤2,000), indicating number of test cases.For each test cast, the first line contains 3 integers N, k and r (1≤N≤20, 1≤k≤52,1≤r≤min(k,25)) as the description above. In the second line, there are N positive float numbers indicates the probability of each gift. There are at most 3 digits after the decimal point. The third line has r integers ranging from 1 to N indicates the finally list of the r best gifts’ ID.OutputFor each case, output a float number with 6 digits after the decimal points, which indicates the probability of the final list.Sample Input42 3 30.3 0.71 1 12 3 30.3 0.71 1 22 3 30.3 0.71 2 22 3 30.3 0.72 2 2Sample Output0.0270000.1890000.4410000.343000Problem C Floor problemAccept: 133 Submit: 150Time Limit: 1000 mSec Memory Limit : 32768 KB Problem DescriptionIn this problem, we have f(n,x)=Floor[n/x]. Here Floor[x] is the biggest integer such that no larger than x. For example, Floor[1.1]=Floor[1.9]=1, Floor[2.0]=2.You are given 3 positive integers n, L and R. Print the result off(n,L)+f(n,L+1)+...+f(n,R), please.InputThe first line of the input contains an integer T (T≤100), indicating the number of test cases.Then T cases, for any case, only 3 integers n, L and R (1≤n, L, R≤10,000,L≤R). OutputFor each test case, print the result of f(n,L)+f(n,L+1)+...+f(n,R) in a single line. Sample Input31 2 3100 2 100100 3 100Sample Output382332Problem D Digits CountAccept: 11 Submit: 64Time Limit: 10000 mSec Memory Limit : 262144 KB Problem DescriptionGiven N integers A={A[0],A[1],...,A[N-1]}. Here we have some operations:Operation 1: AND opn L RHere opn, L and R are integers.For L≤i≤R, we do A[i]=A[i] AND opn (here "AND" is bitwise operation).Operation 2: OR opn L RHere opn, L and R are integers.For L≤i≤R, we do A[i]=A[i] OR opn (here "OR" is bitwise operation).Operation 3: XOR opn L RHere opn, L and R are integers.For L≤i≤R, we do A[i]=A[i] XOR opn (here "XOR" is bitwise operation).Operation 4: SUM L RWe want to know the result of A[L]+A[L+1]+...+A[R].Now can you solve this easy problem?InputThe first line of the input contains an integer T, indicating the number of test cases. (T≤100)Then T cases, for any case, the first line has two integers n and m (1≤n≤1,000,000, 1≤m≤100,000), indicating the number of elements in A and the number of operations.Then one line follows n integers A[0], A[1], ..., A[n-1] (0≤A[i]<16,0≤i<n).Then m lines, each line must be one of the 4 operations above. (0≤opn≤15) OutputFor each test case and for each "SUM" operation, please output the result with a single line.Sample Input14 41 2 4 7SUM 0 2XOR 5 0 0OR 6 0 3SUM 0 2Sample Output718HintA = [1 2 4 7]SUM 0 2, result=1+2+4=7;XOR 5 0 0, A=[4 2 4 7];OR 6 0 3, A=[6 6 6 7];SUM 0 2, result=6+6+6=18.Problem E How many tuplesAccept: 0 Submit: 0Time Limit: 10000 mSec Memory Limit : 65536 KB Problem DescriptionGiven m positive integer a[1],a[2]…a[m]. We run the following program (in C++):const int MAXN = 20;int a[MAXN], m;int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}long long cnt = 0;void gao(int cur, int g) {if (cur > m) {if (g == 1)++cnt;return;}for (int i = 1; i <= a[cur]; ++i)gao(cur + 1, g < 0 ? i : gcd(g, i));}int main() {scanf("%d", &m);for (int i = 1; i <= m; ++i)scanf("%d", a + i);gao(1, -1);cout << cnt << endl;return 0;}Here gcd is the Greatest Common Divisor, Obviously, the program above is to find the number of tuples (b[1], b[2], …, b[m]) such that:(1) gcd(b[1], b[2], …, b[m])=1. (Here we define gcd(num)=num, that is: gcd(9)=9, gcd(2)=2)(2) 1≤b[i]≤a[i]. (1≤i≤m, b[i] is an integer)Now in this problem, the m and a[i] may be very large! So could you write one efficient program to find the answer? The answer may be too large. So you can just output the answer Mod 1,000,000,007.InputThe first line of the input contains an integer T (T≤10,000), indicating the number of test cases.Then T cases, for any case, only two lines.The first line is one integer m(1≤m≤20).The second line has m integers indicate a[1], a[2], …, a[m] (1≤a[i]≤100,000,000,1≤i≤m).The answer may be too large. So you can just output the answer Mod 1,000,000,007. OutputFor each test case, print a line containing the answer Mod 1,000,000,007. Sample Input325 5210000 987321234 5678Sample Output19600261564261566Problem F Hua Rong DaoAccept: 22 Submit: 66Time Limit: 1000 mSec Memory Limit : 32768 KB Problem DescriptionCao Cao was hunted down by thousands of enemy soldiers when he escaped from Hua Rong Dao. Assuming Hua Rong Dao is a narrow aisle (one N*4 rectangle), while Cao Cao can be regarded as one 2*2 grid. Cross general can be regarded as one 1*2grid.Vertical general can be regarded as one 2*1 grid. Soldiers can be regarded as one 1*1 grid. Now Hua Rong Dao is full of people, no grid is empty.There is only one Cao Cao. The number of Cross general, vertical general, and soldier is not fixed. How many ways can all the people stand?InputThere is a single integer T (T≤4) in the first line of the test data indicating that there are T test cases.Then for each case, only one integer N (1≤N≤4) in a single line indicates the length of Hua Rong Dao.OutputFor each test case, print the number of ways all the people can stand in a single line. Sample Input212Sample Output18HintHere are 2 possible ways for the Hua Rong Dao 2*4.Problem H Mountain NumberAccept: 2 Submit: 7Time Limit: 1000 mSec Memory Limit : 32768 KB Problem DescriptionOne integer number x is called "Mountain Number" if:(1) x>0 and x is an integer;(2) Assume x=a[0]a[1]...a[len-2]a[len-1](0≤a[i]≤9, a[0] is positive). Any a[2i+1] is larger or equal to a[2i] and a[2i+2](if exists).For example, 111, 132, 893, 7 are "Mountain Number" while 123, 10, 76889 are not "Mountain Number".Now you are given L and R, how many "Mountain Number" can be found between L and R (inclusive) ?InputThe first line of the input contains an integer T (T≤100), indicating the number of t est cases.Then T cases, for any case, only two integers L and R (1≤L≤R≤1,000,000,000). OutputFor each test case, output the number of "Mountain Number" between L and R in a single line.Sample Input31 101 1001 1000Sample Output954384Problem I StarAccept: 78 Submit: 320Time Limit: 1000 mSec Memory Limit : 32768 KB Problem DescriptionOverpower often go to the playground with classmates. They play and chat on the playground. One day, there are a lot of stars in the sky. Suddenly, one of Overpower’s classmates ask him: “How many acute triangles whose inner angles are less than 90 degrees (regarding stars as points) can be found? Assuming all the stars are in the same plane”. Please help him to solve this problem.InputThe first l ine of the input contains an integer T (T≤10), indicating the number of test cases.For each test case:The first line contains one integer n (1≤n≤100), the number of stars.The next n lines each contains two integers x and y (0≤|x|, |y|≤1,000,000) indicat e the points, all the points are distinct.OutputFor each test case, output an integer indicating the total number of different acute triangles.Sample Input130 010 05 1000Sample Output1Problem J Min NumberAccept: 85 Submit: 261Time Limit: 1000 mSec Memory Limit : 32768 KB Problem DescriptionNow you are given one non-negative integer n in 10-base notation, it will only contain digits ('0'-'9'). You are allowed to choose 2 integers i and j, such that: i!=j, 1≤i<j≤|n|, here |n| mea ns the length of n’s 10-base notation. Then we can swap n[i] and n[j].For example, n=9012, we choose i=1, j=3, then we swap n[1] and n[3], then we get 1092, which is smaller than the original n.Now you are allowed to operate at most M times, so what is the smallest number you can get after the operation(s)?Please note that in this problem, leading zero is not allowed!InputThe first line of the input contains an integer T (T≤100), indicating the number of test cases.Then T cases, for any case, only 2 integers n and M (0≤n<10^1000, 0≤M≤100) in a single line.OutputFor each test case, output the minimum number we can get after no more than M operations.Sample Input39012 09012 19012 2Sample Output901210921029Problem K TicketsAccept: 14 Submit: 50Time Limit: 3000 mSec Memory Limit : 32768 KB Problem DescriptionYou have won a collection of tickets on luxury cruisers. Each ticket can be used only once, but can be used in either direction between the 2 different cities printed on the ticket. Your prize gives you free airfare to any city to start your cruising, and free airfare back home from wherever you finish your cruising.You love to sail and don't want to waste any of your free tickets. How many additional tickets would you have to buy so that your cruise can use all of your tickets?Now giving the free tickets you have won. Please compute the smallest number of additional tickets that can be purchased to allow you to use all of your free tickets. InputThere is one integer T (T≤100) in the first line of the input.Then T cases, for any case, the first line contains 2 integers n, m (1≤n, m≤100,000). n indicates the identifier of the cities are between 1 and n, inclusive. m indicates the tickets you have won.Then following m lines, each line contains two integers u and v (1≤u, v≤n), indicates the 2 cities printed on your tickets, respectively.OutputFor each test case, output an integer in a single line, indicates the smallest number of additional tickets you need to buy.Sample Input35 31 31 24 56 51 31 21 61 51 43 21 21 2Sample Output12。