国际大学生程序设计竞赛2019年赛题
Problem AAzulejosTime limit:10secondsAzulejo in the cathedral of Porto.Source:Wikimedia CommonsCeramic artists Maria and João are opening a small azulejo store in Porto.Azule-jos are the beautiful ceramic tiles for which Portugal is famous.Maria and João want to create an attractive window display,but,due to limited space in their shop,they must arrange their tile samples in two rows on a single shelf.Each of João’s tiles has exactly one of Maria’s tiles in front of it and each of Maria’s tiles has exactly one of João’s tiles behind it.These hand-crafted tiles are of many different sizes,and it is important that each tile in the back row is taller than the tile in front of it so that both are visible to passers-by.For the convenience of shoppers,tiles in each row are arranged in non-decreasing order of price from left to right.Tiles of the same price may be arranged in any order subject to the visibility condition stated above.Your task is to find an ordering of the tiles in each row that satisfies these constraints,or determine that no such ordering exists.InputThe first line of input contains an integer n (1≤n ≤5·105),the number of tiles in each row.The next four lines contain n integers each;the first pair of lines represents the back row of tiles and the second pair of lines represents the front row.Tiles in each row are numbered from 1to n according to their ordering in the input.The first line in each pair contains n integers p 1,...,p n (1≤p i ≤109for each i ),where p i is the price of tile number i in that row.The second line in each pair contains n integers h 1,...,h n (1≤h i ≤109for each i ),where h i is the height of tile number i in that row.OutputIf there is a valid ordering,output it as two lines of n integers,each consisting of a permutation of the tile numbers from 1to n .The first line represents the ordering of the tiles in the back row and the second represents the ordering of the tiles in the front row.If more than one pair of permutations satisfies the constraints,any such pair will be accepted.If no ordering exists,output impossible .Sample Input 1Sample Output 14321223432121221332414213Sample Input 2Sample Output 2212232821impossibleThis page is intentionally left blank.Problem BBeautiful BridgesTime limit:10secondsExample of a Roman arch bridge.Source:Wikimedia CommonsWhat connects us all?Well,it is often bridges.Since an-cient times,people have been building bridges for roads,for trains,for pedestrians,and as aqueducts to transport water.It is humanity’s way of not taking inconvenient geography for an answer.The company Arch Bridges Construction (ABC)specializes in—you guessed it—the construction of arch bridges.This classical style of bridge is supported by pillars that extend from the ground below the bridge.Arches between pillars dis-tribute the bridge’s weight onto the adjacent pillars.The bridges built by ABC often have pillars spaced at irregular intervals.For aesthetic reasons,ABC’s bridges always have semicircular arches,as illustrated in Figure B.1.However,while a bridge arch can touch the ground,it cannot extend below the ground.This makes some pillar placements impossible.rd(a)Consecutive pillars at distance d are connected by a semicircular arch with radius r =d/2.(b)An invalid pillar placement (arches cannot extend belowground).(c)A bridge corresponding to Sample Input 1.Figure B.1:Bridge examples.Given a ground profile and a desired bridge height h ,there are usually many ways of building an arch bridge.We model the ground profile as a piecewise-linear function described by n key points (x 1,y 1),(x 2,y 2),...,(x n ,y n ),where the x -coordinate of a point is the position along the bridge,and the y -coordinate is the elevation of the ground above sea level at this position along the bridge.The first and last pillars must be built at the first and last key points,and any intermediate pillars can be built only at these key points.The cost of a bridge is the cost of its pillars (which is proportional to their heights)plus the cost of its arches (which is proportional to the amount of material used).So a bridge with k pillars of heights h 1,...,h k that are separated by horizontal distances d 1,...,d k −1has a total cost ofα·k i =1h i +β·k −1 i =1d 2ifor some given constants αand β.ABC wants to construct each bridge at the lowest possible cost.InputThefirst line of input contains four integers n,h,α,andβ,where n(2≤n≤104)is the number of points describing the ground profile,h(1≤h≤105)is the desired height of the bridge above sea level, andα,β(1≤α,β≤104)are the cost factors as described earlier.Then follow n lines,the i th of which contains two integers x i,y i(0≤x1<x2<...<x n≤105and0≤y i<h),describing the ground profile.OutputOutput the minimum cost of building a bridge from horizontal position x1to x n at height h above sea level.If it is impossible to build any such bridge,output impossible.Sample Input1Sample Output16460560182002020301050307020Sample Input2Sample Output2impossible41011001999100Problem CChecks Post FactoTime limit:1secondYour university’s board game club just hosted a Checkers tournament,and you were assigned to take notes on the games.Unfortunately,while walking home,you dropped all of your papers into a puddle! Disaster!Much of what you wrote is now unreadable;all you have left are some lists of moves played in the middle of various games.Is there some way you can reconstruct what happened in those games? You had betterfix things fast,or they will demote you to Tic-Tac-Toe recordkeeper!Checkers(or English Draughts)is a well-known board game with simple rules.It is played on the dark squares of an8×8checkerboard.There are two players,Black and White,who alternate turns moving their pieces(all of Black’s pieces are black and all of White’s pieces are white).Each piece occupies a single dark square,and can be either a normal man or a promoted king.A turn consists of choosing one piece and moving it in one of two ways:1.Shifting it diagonally to an unoccupied adjacent dark square,as shown in Figure C.1(a).This iscalled a simple move.If the piece is a man,it can move only in the two diagonal directions towards the opposing side of the board(towards the bottom for Black,the top for White).If the piece is a king,it can move in all four diagonal directions.2.Jumping over an adjacent enemy piece to an unoccupied square immediately on the other side,then removing(capturing)that piece.Men can jump only in the two directions described above, while kings can jump in all four.The player can then repeat this step,continuing to jump with the same piece as long as there are properly-positioned enemy pieces to capture.Such a sequence of one or more jumps is called a jump move.Figure C.1(b)shows a jump move comprising three jumps.(a)Simple move(b)Jumpmove(c)Board numberingFigure C.1:(a),(b)Thefirst two moves in Sample Input1.The larger pieces are kings andthe smaller ones are men.Black sits at the top and White at the bottom.(c)Numberingused in the input.In Checkers,captures are forced moves.If a jump move is available at the start of a player’s turn,they must jump,and cannot stop jumping with that piece until it has no more possible jumps.They are free to choose which piece to jump with,and where,if there are multiple possibilities.In Figure C.1(b),Black could not have made any other move.If a man reaches the farthest row from its player(that is,a black man reaches the bottom row or a white man reaches the top row),it is removed from the board and replaced by a king of the same color(it is said to be promoted),and the turn ends.A piece cannot be promoted and then jump backwards as a new king in the same turn.Given a list of moves,find a setup of pieces such that the moves can be legally played in sequence starting from that setup.This setup may not have black men on the bottom row or white men on the top row,since they would have been promoted to kings already.You need only ensure that the rules above are obeyed;you do not need to ensure that this setup is reachable in a real game of Checkers.InputThefirst line of input contains a character c and an integer n,where c∈{B,W}indicates which player makes thefirst move(Black or White respectively)and n(1≤n≤100)is the number of moves in the list.Then follow n lines,each of which describes a move in the standard Checkers notation defined below.The dark squares are identified by numbers1–32,as shown in Figure C.1(c).A simple move from square a to square b is written as a-b.A jump move starting at a and jumping to b1,b2,...,b k is written as a x b1x b2x···x b k.There is always a valid solution for the given set of moves.OutputOutput two boards side-by-side(separated by a space),giving the positions of all pieces on the board before(on the left)and after(on the right)the given e‘-’for light squares,‘.’for empty dark squares,lowercase‘b’and‘w’for black and white men,and uppercase‘B’and‘W’for black and white kings.If there is more than one valid solution,any one is acceptable.Sample Input1Sample Output1W321-1713x22x31x24 19x28-b-.-.-.-b-.-.-. .-.-.-.-.-.-.-.--.-.-.-.-.-.-.-. B-.-w-.-.-.-w-.--.-.-W-.-.-.-.-. w-.-.-.-.-.-.-.--.-w-w-.-.-.-.-W .-.-.-.-.-.-.-.-Sample Input2Sample Output2B52-79x232-272x11x18 5-9-.-b-.-W-.-.-.-W b-b-.-.-.-.-.-.--w-.-.-.-b-.-.-. B-w-b-.-B-w-.-.--.-.-.-.-.-W-.-. .-.-.-.-.-.-.-.--.-.-.-.-.-.-B-. .-.-.-B-.-.-.-.-Problem DCircular DNATime limit:3secondsYou have an internship with a bioinformatics research group studying DNA.A single strand of DNA consists of many genes,which fall into different categories called gene types.Gene types are delimited by specific nucleotide sequences known as gene markers.Each gene type i has a unique start marker s i and a unique end marker e i.After many dirty jobs(growing bacteria,cell extraction,protein engineering, and so on),your research group can convert DNA into a form consisting of only the gene markers, removing all the genetic material lying between the markers.Your research group came up with the interesting hypothesis that gene interpretation depends on whether the markers of some gene types form properly nested structures.To decide whether markers of gene type i form a proper nesting in a given sequence of markers w,one needs to consider the subsequence of w containing only the markers of gene type i(s i and e i),leaving none of them out.The following(and only the following)are considered to be properly nested structures:•s i e i•s i N e i,where N is a properly nested structure•AB,where A and B are properly nested structuresGiven your computing background,you were assigned to investigate this property,but there is one further complication.Your group is studying a specific type of DNA called circular DNA,which is DNA that forms a closed loop.To study nesting in circular DNA,it is necessary to cut the loop at some location,which results in a unique sequence of markers(the direction of reading isfixed by molecular properties).Whether a gene type i forms a proper nesting now also depends on where the circular DNA is cut.Your task is tofind the cutting location that maximizes the number of gene types that form a properly nested structure.Figure D.1shows an example corresponding to Sample Input1.The indicatednested.cut results in the markers for gene type1being properlyInputThefirst line of input contains an integer n(1≤n≤106),the length of the DNA.The next line contains the DNA sequence,that is,n markers.Each marker is a character c followed by an integer i, where c∈{s,e}specifies whether it is a start or an end marker and i(1≤i≤106)is the gene type of the marker.The given DNA sequence has been obtained from the circular DNA by cutting at an arbitrary location.OutputOutput one line with two integers p and m,where p is the cutting position that maximizes the number of different gene types that form a proper nesting,and m is this maximum number of gene types.The DNA is cut just before the p th input marker(for instance,the cut shown in Figure D.1has p=3).If more than one cutting position yields the same maximum value of m,output the smallest p that does so. Sample Input1Sample Output1931e1e1s1e2s1s2e42e1s1Sample Input2Sample Output2882s1s1e3e1s3e1e3s3Problem EDead-End DetectorTime limit:5secondsA dead-end sign.Source:Wikimedia CommonsThe council of your home town has decided to improve road sign placement,especially for dead ends.They have given you a road map,and you must determine where to put up signs to mark the dead ends.They want you to use as few signs as possible.The road map is a collection of locations connected by two-way streets.The following rule describes how to obtain a complete placement of dead-end signs.Consider a street S connecting a location x with another location.The x -entrance of S gets a dead-end sign if,after entering S from x ,it is not possible to come back to x without making a U-turn.A U-turn is a 180-degree turn immediately reversing the direction.To save costs,you have decided not to install redundant dead-end signs,as specified by the following rule.Consider a street S with a dead-end sign at its x -entrance and another street T with a dead-end sign at its y -entrance.If,after entering S from x ,it is possible to go to y and enter T without making a U-turn,the dead-end sign at the y -entrance of T is redundant.See Figure E.1forexamples.(a)Sample Input 1(b)Sample Input 2Figure E.1:Illustration of sample inputs,indicating where non-redundant dead-end signs are placed.InputThe first line of input contains two integers n and m ,where n (1≤n ≤5·105)is the number of locations and m (0≤m ≤5·105)is the number of streets.Each of the following m lines contains two integers v and w (1≤v <w ≤n )indicating that there is a two-way street connecting locations v and w .All location pairs in the input are distinct.OutputOn the first line,output k ,the number of dead-end signs installed.On each of the next k lines,output two integers v and w marking that a dead-end sign should be installed at the v -entrance of a street connecting locations v and w .The lines describing dead-end signs must be sorted in ascending order of v -locations,breaking ties in ascending order of w -locations.Sample Input1Sample Output165 12 13 23 45 562 45 65Sample Input2Sample Output288 12 13 23 34 15 16 67 683 15 16 34Problem FDirecting RainfallTime limit:15secondsPorto and the nearby Douro Valley are famous for producing port wine.Wine lovers from all over the world come here to enjoy this sweet wine where it is made.The International Consortium of Port Connoisseurs(ICPC)is organizing tours to the vineyards that are upstream on the Douro River.To make visits more pleasurable for tourists,the ICPC has recently installed sun tarps above the vineyards.The tarps protect tourists from sunburn when strolling among the vines and sipping on a vintage port. Unfortunately,there is a small problem with the tarps.Grapes need sunlight and water to grow.While the tarps let through enough sunlight,they are entirely waterproof.This means that rainwater might not reach the vineyards below.If nothing is done,this year’s wine harvest is in peril!The ICPC wants to solve their problem by puncturing the tarps so that they let rainwater through to the vineyards below.Since there is little time to waste before the rainy season starts,the ICPC wants to make the minimum number of punctures that achieve this goal.We will consider a two-dimensional version of this problem.The vineyard to be watered is an interval on the x-axis,and the tarps are modeled as line segments above the x-axis.The tarps are slanted,that is, not parallel to the x-or y-axes(see Figure F.1for an example).Rain falls straight down from infinitely high.When any rain falls on a tarp,itflows toward the tarp’s lower end and falls off from there,unless there is a puncture between the place where the rain falls and the tarp’s lower end—in which case the rain will fall through the puncture instead.After the rain falls off a tarp,it continues to fall vertically. This repeats until the rain hits the ground(the x-axis).(a)Tarps are shown as black slantedline segments and the vineyard as agreen line segment at thebottom.starts above the vineyard will reachthe vineyard.Figure F.1:Illustration of Sample Input1.For legal reasons you have to ensure that at least some of the rain that reaches the vineyard originated from directly above the vineyard.This is to prevent any vineyard from stealing all their rain from neighboring vineyards(see the second sample input for an example).InputThefirst line of input contains three integers ,r and n,where( ,r)(0≤ <r≤109)is the interval representing the vineyard and n(0≤n≤5·105)is the number of tarps.Each of the following n lines describes a tarp and contains four integers x1,y1,x2,y2,where(x1,y1)is the position of the tarp’s lower end and(x2,y2)is the position of the higher end(0≤x1,x2≤109,x1=x2,and0<y1<y2≤109). The x-coordinates given in the input( ,r,and the values of x1and x2for all tarps)are all distinct.The tarps described in the input will not intersect,and no endpoint of a tarp will lie on another tarp. OutputOutput the smallest number of punctures that need to be made to get some rain falling from above the vineyard to the vineyard.Sample Input1Sample Output11020523250126030608702570080153028405201425Sample Input2Sample Output2242132035215Problem GFirst of Her NameTime limit:10secondsIn the Royal Family,names are very important!As the Royal Historian you have been charged with analyzing the patterns in the names of the Royal Ladies in the realm.There have been n Royal Ladies,for convenience numbered from1to n.The name of each Lady is an uppercase letter concatenated with the name of her mother.The exception is the Lady numbered1,the founder of the Royal Family,whose name is just a single uppercase letter.For example,ENERYS could be the mother of AENERYS(as the name AENERYS consists of the single uppercase letter‘A’concatenated with ENERYS,which is her mother’s name).Similarly,AENERYS could be the mother of DAENERYS and Y AENERYS.You are given the description of all the Royal Ladies.Your task is to determine,for certain interesting strings s,the number of Royal Ladies for whom s is a prefix of their name.For example,consider Sample Input1below,with a Royal Line that goes straight from the founder S to AENERYS(through YS,RYS,ERYS,NERYS and ENERYS),with each Lady having exactly one daughter.Then AENERYS has two daughters—DAENERYS and Y AENERYS,with the latter having one daughter,RY AENERYS.In such a family,RY is a prefix of the names of two ladies:RYS and RY AENERYS.E is a prefix of the names of ERYS and ENERYS.N is a prefix only of NERYS’s name,while S is a prefix only of the name of the founder,S.AY is not a prefix of any Royal Lady’s name.InputThefirst line of input contains two integers n and k,where n(1≤n≤106)is the total number of Royal Ladies and k(1≤k≤106)is the number of query strings.Then follow n lines describing the Royal Ladies.The i th of these lines describes the Royal Lady num-bered i,and contains an uppercase letter c i(‘A’–‘Z’)and an integer p i,where c i is thefirst letter of the name of Lady i,and p i(p1=0and1≤p i<i for i>1)is the number of her mother(or0,in the case of the First Lady).All the names are unique.The remaining k lines each contain one nonempty query string,consisting only of uppercase letters.The sum of the lengths of the query strings is at most106.OutputOutput k lines,with the i th line containing the number of Royal Ladies who have the i th query string as a prefix of their name.Sample Input1Sample Output1105 S0 Y1 R2 E3 N4 E5 A6 D7 Y7 R9 RYENSAY 2 2 1 1 0Problem HHobson’s T rainsTime limit:5secondsMr.Hobson has retired from running a stable and has invested in a more modern form of transport,trains.He has built a rail network with n stations.However,he has retained his commitment to free the passenger from the burden of too many choices:from each station,a passenger can catch a train to exactly one other station.Such a journey is referred to as a leg .Note that this is a one-way journey,and it might not be possible to get back again.Hobson also offers exactly one choice of ticket,which allows a passenger to travel up to k legs in one trip.At the exit from each station is an automated ticket reader (only one,so that passengers do not need to decide which to use).The reader checks that the distance from the initial station to the final station does not exceed k legs.Each ticket reader must be programmed with a list of valid starting stations,but the more memory this list needs,the more expensive the machine will be.Help Hobson by determining,for each station A ,the number of stations (including A )from which a customer can reach A in at most klegs.2,3,4,5,63,4,51,2,3,61,216Figure H.1:Illustration of Sample Input 1.Each circle represents a station.The numbers outside the circles are the station numbers loaded into the ticket readers when k =2.InputThe first line of input contains two integers n and k ,where n (2≤n ≤5·105)is the number of stations and k (1≤k ≤n −1)is the maximum number of legs that may be traveled on a ticket.Then follow n lines,the i th of which contains an integer d i (1≤d i ≤n and d i =i ),the station which may be reached from station i in one leg.OutputOutput n lines,with the i th line containing the number of stations from which station i can be reached in at most k legs.Sample Input1Sample Output162 2345431 2 4 5 3 1Sample Input2Sample Output253 231543 3 3 2 2Problem IKarel the RobotTime limit:10secondsDid you know that the word“robot”is almost100years old?It wasfirst introduced in1920,in the science-fiction theatrical play R.U.R.,written by KarelˇCapek.As a tribute to this Czech writer,an educational programming language was named Karel many years later at Stanford University.Your task is to implement an interpreter of a simplified version of this programming language.The Karel programming language controls a robot named Karel,who lives in a grid of unit squares. Some of the squares are free,while others contain a barrier.Karel always occupies one of the free squares and faces one of the four cardinal directions.The two basic commands are“move forward”and “turn left.”The language also provides simple conditional and looping statements.The main educational potential of the language lies in the possibility of defining new procedures for more complex tasks. Our simplified version of the language can be described by the following grammar:<program>:=""|<command><program><command>:="m"|"l"|<proc-call>|"i"<condition>"("<program>")("<program>")"|"u"<condition>"("<program>")"<condition>:="b"|"n"|"s"|"e"|"w"<proc-call>:=<uppercase-letter><proc-def>:=<uppercase-letter>"="<program>There arefive types of commands:m(“move forward”)advances Karel’s position by one grid square in its current heading,unless there is a barrier,in which case the command has no effect.l(“turn left”)makes Karel turn left90degrees.X where X is any uppercase letter,invokes the procedure named X.i(“if”)followed by a single-letter condition,and two programs in parentheses.If the condition is satisfied,thefirst program is executed.Otherwise,the second program is executed.u(“until”)followed by a single-letter condition,and a program in parentheses.If the condition is satisfied,nothing is done.Otherwise,the program is executed and then the command is repeated.A condition can be either‘b’,which is satisfied if and only if there is a barrier in the next square in Karel’s current heading,or one of the four directional letters‘n’,‘s’,‘e’,or‘w’,which is satisfied if and only if Karel’s current heading is north,south,east,or west,respectively.For instance,a simple program ub(m)can be understood to mean:“keep moving forward until there is a barrier,”while un(l)means“turn to the north.”A procedure definition R=lll defines a new procedure‘R’which effectively means“turn right.”InputThefirst line of input contains four integers r,c,d,and e,where r and c(1≤r,c≤40)are the dimensions of the grid in which Karel lives,d(0≤d≤26)is the number of procedure definitions,and e(1≤e≤10)is the number of programs to be executed.Then follow r lines describing the grid(running north to south),each containing c characters(running west to east),each character being either‘.’(denoting a free square)or‘#’(denoting a barrier).All squares outside this given area are considered barriers,which means Karel may never leave the area. Each of the next d lines contains a procedure definition,associating a procedure name(one uppercase letter)with a program forming the procedure body.No procedure name is defined more than once. Procedure bodies may contain invocations of procedures that have not yet been defined.The last2e lines describe the programs to be executed.Each such description consists of a pair of lines. Thefirst line of each pair contains two integers i and j and a character h,where i(1≤i≤r)is the row and j(1≤j≤c)is the column of Karel’s initial position,and h∈{n,s,e,w}represents Karel’s initial heading.It is guaranteed that the initial position is a free square.The second line of each pair contains a program to be executed from that initial position.All procedure bodies and all programs to be executed are at least1and at most100characters long,syn-tactically correct,and only contain invocations of procedures that are defined.The lines with procedure definitions and programs to be executed contain no whitespace characters.OutputFor each program execution,output thefinal position of Karel after the complete program is executed from the respective initial position.Follow the format used to describe initial positions,that is,two numbers and a directional character.If a particular execution never terminates,output inf instead. Sample Input1Sample Output14857.......#..#....#.###...#.....###R=lllG=ub(B)B=ub(m)lib(l)(m)H=ib()(mmHllmll)I=III11wG11eG22nG26wBR41sib(lib()(mmm))(mmmm) 11eH22sI 11w inf 11w 24s 44e 14e infProblem JMiniature GolfTime limit:6secondsA group of friends has just played a round of miniature golf.Miniature golf courses consist of a number of holes.Each player takes a turn to play each hole by hitting a ball repeatedly until it drops into the hole.A player’s score on that hole is the number of times they hit the ball.To prevent incompetent players slowing down the game too much,there is also an upper limit (a positive integer)on the score:if a player has hit the ball times without the ball dropping into the hole,the score for that hole is recorded as and that player’s turn is over.The total score of each player is simply the sum of their scores on all the holes.Naturally,a lower score is considered better.There is only one problem:none of the players can remember the value of the integer .They decide that they will not apply any upper limit while playing,allowing each player to keep playing until the ball drops into the hole.After the game they intend to look up the value of and adjust the scores,replacing any score on a hole that is larger than with .The game has justfinished,but the players have not yet looked up .They wonder what their best possible ranks are.For this problem,the rank of a player is the number of players who achieved an equal or lower total score after the scores are adjusted with .For example,if the adjusted scores of the players are3,5,5,4,and3,then their ranks are2,5,5,3and2respectively.Given the scores of the players on each hole,determine the smallest possible rank for each player. InputThefirst line of input contains two integers p and h,where p(2≤p≤500)is the number of players and h(1≤h≤50)is the number of holes.The next p lines each contain h positive integers.The j th number on the i th of these lines is the score for player i on hole j,and does not exceed109.OutputOutput a line with the minimum possible rank for each player,in the same order as players are listed in the input.Sample Input1Sample Output133 222 421 4411 2 2Sample Input2Sample Output264 3122 4322 6632 7343 3424 23351 2 5 5 4 3。
最新2019年大学JAVA程序语言设计期末完整考试题库500题(含标准答案)
2019年大学JAVA期末题库500题[含参考答案]一、判断题1.下列代码的执行结果是:int a="hello".length();system.out.println(a); ( a ) 652102.下列不是合法for语句的是(B )。
for(表达式1;;)for(表达式1,表达式2,表达式3)for(;表达式2;)for(;;表达式3)3.在JAVA中,( )关键字用来终止循环语句。
cReturnContinueBreakExit4.以下( c )不是Java的原始数据类型。
shortbooleanunitfloat5.在JAVA中下面哪一行代码不出现编译警告或错误( d )。
float f=1.3;char c="a";byte b=257;int i=10;6.对public void add(int a) {…}方法的重载方法应返回(b )voidintfloat任何类型7.内部数据类型byte的取值范围是( B )0——65-128——127–32768——32767256—— 2558.在单一文件中import.class和package的正确出现顺序是( a )。
package, import, classclass, import, packageimport, package, classpackage, class, import9.下列不属于关系运算符的是(c )。
><>>!=10.下列不属于表达式语句的是( c )。
++i;--j;b#a;b+=a;11.下列选项中,与成员变量共同构成一个类得是( a )。
关键字方法运算符表达式12.下列数中为八进制的是( c )。
270x2502602813.若定义int a=2,b=2,下列表达式中值不为4的是( a )。
a+(++b);a*(b++);a+b;a*b;14.815.016.测试文件是否存在可以采用如下哪个方法( A)。
2019常州市中小学生程序设计小能手比赛试题
猜先(a.cpp)问题描述小X凭借出色的棋艺被聘请为少年宫的中国象棋老师。
少年宫改造以后所有的设施都焕然一新,象棋教室已不再使用传统的木制棋子和棋盘了,小朋友们所有的操作都是在电脑上进行的,如猜先、对弈、复盘、计算积分等,这给老师的备课带来了极大的挑战,因为除了正常的棋艺教学,还要开发各种应用程序来辅助教学。
众所周知任何棋类运动开局前都要猜先,如围棋项目猜先仪式是由上手抓起一把围棋子让对手猜单双,猜中先行。
而象棋则是甲、乙两人同时从各自的棋盒中摸出一枚棋子比大小,连续比三次,获胜次数多的一方执红先行,另一方则执黑后行。
因现在所有的操作都要在电脑上实现,小X需要编写一个象棋猜先程序,具体任务如下:象棋中有七种棋子,分别是帅、士、相、车、马、炮、兵,程序中用7,6,5,4,3,2,1表示,定义大小的规则为:帅>士>相>车>马>炮,兵最弱,除了帅之外的棋子都比兵大,士>相>车>马>炮>兵,但兵却能吃帅,即兵>帅。
猜先程序要能实现以下功能:输入三行数据,每行两个棋子的编号,判断谁胜谁负。
小X觉得这个程序太简单了,于是交给了参加本次比赛的你来完成。
输入格式输入数据共有三行,每行两个用空格隔开的正整数,表示两个棋子对应的编号,第一个数对应甲摸出的棋子的编号,第二个数对应乙摸出的棋子的编号。
输出格式输出一行包含一个单词,如甲获胜的次数比乙多则输出“Win”,如乙获胜的次数多则输出“Lose”,如甲乙两人获胜次数相同则输出“Tie”。
请注意大小写,引号不用输出!样例输入6 23 37 1样例输出Tie样例解释第一次甲摸出的棋子是士,编号为6,乙摸出的棋子是炮,编号为2,甲胜;第二次甲乙摸出的棋子都是马,编号为3,平;第三次甲摸出的棋子是帅,编号为7,乙摸出的棋子是兵,编号为1,乙胜;三次比下来结果为平手。
数据范围对于30%的数据不会出现7对于100%的数据,每种结果对应的数据均不少于1/3投篮(b.cpp)问题描述小X刚把猜先的程序交给少年宫的小朋友就接到了健身教练的电话,教练要求他马上到中天体育馆练习投篮,之所以选择投篮这个项目,主要目的是要在帮助小X减肥的同时还能预防颈椎病,小X每次必须投满规定的积分才能结束投篮,积分规则是这样的:小X每投中一个球得1分,如果没投中但球碰到了篮框、篮板或篮网则既不得分也不扣分,如果球啥也没碰到(俗称三不沾)则倒扣1分,作为奖励小X如能连续投中3球则额外加1分,如连续投中4球则额外加2分,依次类推,即连续投中K球(K>=3)则额外加K-2分,教练每次给小X计分都很辛苦,于是他要求小X设计一个能自动计分的程序,小X觉得这个程序也很简单,于是他把这个任务又交给了你!输入格式输入数据共有两行,第一行为一个正整数n,表示小X共进行了n次投篮,第二行为一个由n个字符组成的字符串,该字符串只包含三种字符,分别是大写字母’V’,’T’,’X’,其中’V’表示投中了,’T’表示没投中但不用扣分,’X’表示要扣1分。
电大1411《程序设计基础(本)》开放大学期末考试试题2019年7月(含答案)
试卷代号: 1411
国家开放大学 2019 年春季学期期末统一考试
程序设计基础(本) 试题答案及评分标准
(供参考)
2019 年 7 月
一、单项选择题(把合适的选项编号填写在括号内。每小题 3 分,共 30 分)
1.A
2 .A 7 .B
3. A
4. C
21. B
22.B
23. C
24. B
25. A
四、编程题(共 10 分)
26. 打印边长为 m 的正方型。要求:从键盘输入 m 值,输出 m 行,每行 m 个"*"号组成
的正方形。例:输入 m=4, 输出的图形如下:
**** ****
****
****
正确编写程序给满分。其它酌情给分。
1225
提醒:电大资源网已将该科目2010年到2020年1月的期末试题
main()
{ int j;
for (j=O;j<lO;j++)
{if (j%2 = =O) contmue;
printfC" %d" ,j);
@ C,D @ E,C,D
}
该程序的执行结果是
。(
)
A. 1 3 5 7 9
B. 1 3 5 7
C. 2 4 6 8
D. 0 2 4 6 8 1223
提醒:电大资源网已将该科目2010年到2020年1月的期末试题
)。
A. 面向过程的程序设计语言
B. 面向问题的程序设计语言
C. 面向对象的程序设计语言
D. 面向硬件的程序设计语言 1220
提醒:电大资源网已将该科目2010年到2020年1月的期末试题
江南大学大学生学科竞赛目录
82
“学创杯”全国大学生 综合模拟大赛
教育部高等学校统计学类专业 教学指导委员会
B
83
江苏省大学生国联证券杯 理财高手大赛
共青团江苏省委、江苏省学生联合会
B
84
“福斯特杯”全国大学生 审计精英挑战赛
中国商业会计学会
B
85
江苏省普通高等学校 高等数学竞赛
江苏省教育厅、 江苏省高等学校数学教学研究会
B
管理责任 学院/部门
中国化工学会、中国化工教育协会、 教育部高等学校化工类专业 教学指导委员会
中国石油和化学工业联合会、 中国化工教育协会
B
化学与材料工程 学院
B
化学与材料工程 学院
B
化学与材料工程 学院
47
全国大学生化工实验大赛
教育部高等学校化工类专业教学指导委员 会、中国化工教育协会
B
化学与材料工程 学院
48
江苏省大学生化学化工实验 竞赛
27
全国食品安全科普创新竞赛
国家食品药品监督管理总局新闻中心、 中国食品工业协会
B
28 盼盼食品杯烘焙食品创意大赛
中国食品科学技术学会、 福建盼盼食品集团
B
中国科学食品技术学会、
29
杜邦两岸食品创意竞赛
台湾食品工业发展研究所、
B
台湾食品科学技术学会等
30
李锦记杯学生创新大赛
中国食品科学技术学会
B
管理责任 学院/部门 食品学院
B
管理责任 学院/部门
机械学院
机械学院
94 “丝绸之路”机器人创意大赛 中国自动化学会、丝绸之路大学联盟
B
95
中国机械行业卓越工程师 教育联盟毕业设计大赛
校企合作简报
信息工程学院校企合作简报The Briefing of the Cooperation between School and Enterprise2019年第1期(总第14期)信息工程学院学工办编印 2019年3月【本期导读】信息工程学院赴校企合作实训基地看望实习学生 (2)信息工程学院多次召开校企合作专题工作会议 (3)信息工程学院教师第三党支部参观华为南研所并举行教学研讨会 (4)信息工程学院举办专题研讨会推进学院创新创业工作 (5)信工学子在多类学科竞赛中获奖 (6)双创名师走进信工院助力学子规划职业生涯 (8)信息工程学院举办首届微信小程序设计大赛颁奖典礼暨专题分享会 (9)【班级动态】 (10)【企业活动风采录】 (15)【工作简讯】信息工程学院赴校企合作实训基地看望实习学生为进一步促进校企联合培养人才机制的健康发展,切实做好校企合作协议条款落实情况跟踪调查,我院学生工作负责人、软件工程专业负责人、年级辅导员赴万和卡子门校区、南通甲骨文技术人才创新实训基地看望我院实训学生。
2018年9月29日,学院党总支书记陈长伟、副院长王勇参加“晓庄学院-江苏万和嵌入式培养实训效果检查座谈会”。
万和教学技术总监苏老师与院校部陈经理负责接待。
院领导一行参观了晓庄学生在实训室上课的情景,并共同探讨此次嵌入式实训的具体情况。
参加实训的一些学生和老师们分享了这段时间自己学习的感受,并谈了谈自己未来的发展规划。
2018年11月1日,学院党总支副书记陈华锋、软件工程专业负责人,以及2015年级辅导员一同赴南通甲骨文技术人才创新实训基地看望我院实训学生。
学院领导老师先实地参观了学生实训场所,现场了解了学生实训情况。
随后,在召开的校企座谈会上,实训基地负责人钱杰将企业实践教学安排、学生实训情况及学生未来就业推荐工作安排情况做了详细介绍。
学院领导老师与实训学生代表进行了亲切的座谈交流,详细了解他们的学习和生活情况,并就学生反映的教学进度过快,教学资源及实训项目选择偏少等问题与企业进行交流。
2015-2019年全国普通高校学科竞赛排行榜内竞赛项目名单
8 全国高等医学院大学生临床技能竞赛
9 全国大学生机械创新设计大赛
10 全国大学生结构设计竞赛
11 全国大学生广告艺术大赛
12 全国大学生智能汽车竞赛
13 全国大学生交通科技大赛
14 全国大学生电子商务“创新、创意及创业”挑战赛
15 全国大学生节能减排社会实践与科技竞赛
16 全国大学生工程训练综合能力竞赛
41 全国大学生集成电路创新创业大赛
注:
清单每年都可能变动,此表仅作机自学院2021年免试攻读硕士学位研究生竞赛成果用。
附件
三
2015-2019年全国普通高校学科竞赛排行榜内径赛项目名单
序号 生创新创业大赛
2 “挑战杯”全国大学生课外学术科技作品竞赛
3 “挑战杯”中国大学生创业计划大赛
4 ACM-ICPC国际大学生程序设计竞赛
5 全国大学生数学建模竞赛
6 全国大学生电子设计竞赛
7 全国大学生化学实验邀请赛
31 全国周培源大学生力学竞赛
32 中国大学生机械工程创新创意大赛
33 蓝桥杯全国软件和信息技术专业人才大赛
34 全国大学生金相技能大赛
35 “中国软件杯”大学生软件设计大赛
36 全国大学生光电设计竞赛
37 全国高校数字艺术设计大赛
38 中美青年创客大赛
39 全国大学生地质技能竞赛
40 米兰设计周-中国高校设计学科师生优秀作品展
24 中国大学生计算机设计大赛
25 中国大学生市场调查与分析大赛
26 中国大学生服务外包创新创业大赛
27 两岸新锐设计竞赛“华灿奖”
28
中国高校计算机大赛-大数据挑战赛、团体程序设计天梯赛、移动应用创新赛、网络技术 挑战赛
C语言程序设计之乒乓球比赛编排
序号: 01遵守 考 试 纪 律 注意行 为 规 范哈尔滨工业大学(威海)2019 / 2020 学年 春 季学期C 语言程序设计大作业题目(A/B/C )注意事项:请不要将题目要求写到答题卡上,答题卡缺省的难度系数是B ,请确认这份试卷适合你自己的难度选择(A/B/C )。
程序调试通过后,需要将运行过程截图放在文档中,运行程序前或后,请在命令行窗口执行命令date,用来打印系统当前的时间。
截取测试数据和运行过程时,请把时间也一起截图在图像中。
请在设计文档中写清楚自己的学号和姓名,并在源程序中的嵌入自己的姓名学号,一旦发现有人故意泄漏自己的大作业给别人或者抄袭其他同学的文档,各方均按作弊处理,(word 文档和pdf 文档都需要提交)。
源代码单独提交,在答题卡源代码中适当的位置标出注释,如函数要注明用法(输入什么,输出什么,用途,实现方法等),变量(尤其是复杂变量如二维数组)要标注出变量的用途。
提交作业的方式:云班课提交备份,用来核对提交时间(以图片和pdf 两种的方式提交),在规定的时间点,同学们同时提交给课代表,课代表在极短的时间内按照班级分别打包,打包文件名字为“班级号A .zip”、“班级号B .zip”、“班级号C.zip”。
班级每位同学的文档名为学号姓名A/B/C.doc”或者“学号姓名A/B/C .pdf”以及“学号A/B/C.c ”(A/B/C 只写一个)。
提交时间奖惩制度:每种方案的前5名提交作业的同学奖励5分(大作业满分100分,达到100分不再奖励),超过规定时间没有提交大作业的,每逾期1天罚2分。
友情提示:请超级自信的同学选择A 方案,自信的同学选择B 方案,大部分同学请选择C 方案。
乒乓球竞赛制度简介同其它球类竞赛项目一样,乒乓球比赛也多采用循环制和淘汰制两种形式,有时也采用两种 办法结合的混合制。
1、循环制循环制是球类比赛的一种基本和常用的方法,其特点是参加竞赛的各队在整个比赛或小都有相遇的机会,这种方法有利于对手之间的交流和提高技术水平,并且较能公正客观地反映比赛结果,因而成为乒乓球比赛经常采用的方法。
数结课设C题senior麻将试题
吉林大学2019-2020学年第2学期《数据结构》课程设计C题Senior TrackIJCAI 2020 Mahjong AI Competition IJCAI (International Joint Conference on Artificial Intelligence)是人工智能领域历史最悠久的学术会议,也是最重要和最顶级的学术会议之一。
第一届IJCAI于1969年在美国华盛顿举行,是有史以来的第一次人工智能国际会议。
几十年来,众多领先的AI科技成果都是在IJCAI 会议期间提出。
我院与IJCAI会议有着不解之缘。
我国于1979年首次参加IJCAI会议,中国科学院院士、我国人工智能研究奠基人、吉林大学计算机学科创始人王湘浩教授以及来自清华大学、中科院等单位的7位学者参加了此次会议。
此外,IJCAI 2024的大会主席(Conference Chair)将由澳大利亚人工智能理事会理事长、悉尼科技大学副校长张成奇教授担任,这是IJCAI创办50多年来的首位华人大会主席,而张成奇教授正是吉林大学计算机系的杰出校友,是管纪文教授和刘大有教授的高徒。
图1王湘浩院士(前排中间)等7名中国学者参加IJCAI 1979每年IJCAI会议都会举办人工智能编程竞赛(AI Competition),今年IJCAI 2020 AI Competition的项目之一是“麻将”,即编写程序自动打麻将,与其他对手比赛。
我们将此内容作为本次课程设计C题的Senior Track,供有能力有兴趣的同学尝试。
我们将推荐较好完成此题的队伍参加IJCAI 2020 Mahjong AI Competition正式比赛。
麻将起源于中国,而后传播至世界各地,具有相当广泛的群众基础,它是一款拥有超过3000年历史的四人不完全信息博弈游戏。
麻将既需要玩家的运筹帷幄,也需要玩家的运气相助,而这带来的不确定性也为麻将带来了更多的乐趣与挑战,使其具有很强的制约性、趣味性、竞技性、观赏性。
2019年全国大学生数学建模竞赛题目A:高压油管的压力控制优秀论文范例三篇(含源代码)
2019年全国大学生数学建模竞赛题目A:高压油管的压力控制优秀论文范例三篇(含源代码)1. 引言高压油管是发动机燃油喷射系统中的重要组成部分,其压力的控制对于发动机的运行稳定性非常关键。
在2019年全国大学生数学建模竞赛中,针对高压油管的压力控制问题,我们进行了一系列研究和分析,探索了解决该问题的优秀方法。
本文将介绍三篇优秀论文范例,并提供源代码供读者参考。
2. 论文一:基于PID控制算法的高压油管压力控制2.1 问题描述本文从数学建模的角度出发,针对高压油管的压力控制问题提出了一种基于PID控制算法的解决方案。
该问题的要求是在给定的工况下,通过控制高压油泵的开关方式,使得一段时间内高压油管内的压力保持在一个预定的范围内。
2.2 算法设计本文提出了基于PID控制算法的高压油管压力控制方案。
PID控制是一种常用的反馈控制算法,通过不断调整控制器的参数,根据当前误差来调整控制信号。
在该方案中,我们将高压油管的压力误差作为PID控制器的输入,根据控制器输出的控制信号,调整高压油泵的开关状态。
通过不断的反馈调整,使得高压油管内的压力稳定在预定范围内。
2.3 仿真与实验结果本文通过对所提出的高压油管压力控制方案进行仿真与实验,验证了该方案的可行性和有效性。
仿真结果表明,通过PID控制算法,可以在较短的时间内将高压油管内的压力控制在预定范围内。
实验结果也进一步验证了方案的有效性。
2.4 源代码# PID控制算法实现def pid_control(p_error, i_error, d_error):Kp =0.5# 比例系数Ki =0.2# 积分系数Kd =0.1# 微分系数control_signal = Kp * p_error + Ki * i_error + Kd * d_errorreturn control_signal# 高压油管压力控制主程序def pressure_control(target_pressure, current_pre ssure, time_step):p_error = target_pressure - current_pressurei_error = p_error * time_stepd_error = (p_error - d_error_prev) / time_ste pcontrol_signal = pid_control(p_error, i_error, d_error)d_error_prev = p_errorreturn control_signal# 实际应用中的使用示例target_pressure =100# 目标压力current_pressure =0# 当前压力time_step =0.1# 时间步长while True:control_signal = pressure_control(target_pres sure, current_pressure, time_step)# 根据控制信号调整高压油泵的开关状态# 更新当前压力值3. 论文二:基于模型预测控制的高压油管压力控制3.1 问题描述本文针对高压油管的压力控制问题,提出了一种基于模型预测控制(MPC)的解决方案。
2019年全国电子设计大赛D题_简易电路特性测试仪
2019年全国大学生电子设计竞赛试题参赛注意事项(1)8月7日8:00竞赛正式开始。
本科组参赛队只能在【本科组】题目中任选一题;高职高专组参赛队在【高职高专组】题目中任选一题,也可以选择【本科组】题目。
(2)参赛队认真填写《登记表》内容,填写好的《登记表》交赛场巡视员暂时保存。
(3)参赛者必须是有正式学籍的全日制在校本、专科学生,应出示能够证明参赛者学生身份的有效证件(如学生证)随时备查。
(4)每队严格限制3人,开赛后不得中途更换队员。
(5)竞赛期间,可使用各种图书资料和网络资源,但不得在学校指定竞赛场地外进行设计制作,不得以任何方式与他人交流,包括教师在内的非参赛队员必须迴避,对违纪参赛队取消评审资格。
(6)8月10日20:00竞赛结束,上交设计报告、制作实物及《登记表》,由专人封存。
简易电路特性测试仪(D题)【本科组】一、任务设计并制作一个简易电路特性测试仪。
用来测量特定放大器电路的特性,进而判断该放大器由于元器件变化而引起故障或变化的原因。
该测试仪仅有一个输入端口和一个输出端口,与特定放大器电路连接如图1所示。
图1特定放大器电路与电路特性测试仪连接图制作图1中被测放大器电路,该电路板上的元件按图1电路图布局,保留元件引脚,尽量采用可靠的插接方式接入电路,确保每个元件可以容易替换。
电路中采用的电阻相对误差的绝对值不超过5%,电容相对误差的绝对值不超过20%。
晶体管型号为9013,其β在60~300之间皆可。
电路特性测试仪的输出端口接放大器的输入端Ui, 电路特性测试仪的输入端口接放大器的输出端Uo。
二、要求1. 基本要求(1)电路特性测试仪输出1kHz正弦波信号,自动测量并显示该放大器的输入电阻。
输入电阻测量范围1kΩ~50kΩ,相对误差的绝对值不超过10%。
(2)电路特性测试仪输出1kHz正弦波信号,自动测量并显示该放大器的输出电阻。
输出电阻测量范围500Ω~5kΩ,相对误差的绝对值不超过10%。
