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

51nod-2206-低买高卖

题目: 考虑股票市场,一共有n天。 对于第i天,B君知道股票的价格是每单位a[i]元 在每一天,B君可以选择买入一个单位的股票,卖出一个单位的股票,或者什么都不做。 刚开始B君有无穷多的钱,但是没有任何股票。 问n天之后B君最多可以赚多少钱。 (1 <= n <= 200000) (1 <= a[i] <= 10000) ...

September 25, 2019 · 1 min · 143 words · eonh1u

51nod-1649-齐头并进

题目 在一个叫奥斯汀的城市,有n个小镇(从1到n编号),这些小镇通过m条双向火车铁轨相连。当然某些小镇之间也有公路相连。为了保证每两个小镇之间的人可以方便的相互访问,市长就在那些没有铁轨直接相连的小镇之间建造了公路。在两个直接通过公路或者铁路相连的小镇之间移动,要花费一个小时的时间。 现在有一辆火车和一辆汽车同时从小镇1出发。他们都要前往小镇n,但是他们中途不能同时停在同一个小镇(但是可以同时停在小镇n)。火车只能走铁路,汽车只能走公路。 现在请来为火车和汽车分别设计一条线路;所有的公路或者铁路可以被多次使用。使得火车和汽车尽可能快的到达小镇n。即要求他们中最后到达小镇n的时间要最短。输出这个最短时间。(最后火车和汽车可以同时到达小镇n,也可以先后到达。) ...

September 24, 2019 · 2 min · 249 words · eonh1u

cf-587-div3

A题 Prefixes: 题目: Nikolay got a string 𝑠 of even length 𝑛, which consists only of lowercase Latin letters ‘a’ and ‘b’. Its positions are numbered from 1 to 𝑛. He wants to modify his string so that every its prefix of even length has an equal amount of letters ‘a’ and ‘b’. To achieve that, Nikolay can perform the following operation arbitrary number of times (possibly, zero): choose some position in his string and replace the letter on this position with the other letter (i.e. replace ‘a’ with ‘b’ or replace ‘b’ with ‘a’). Nikolay can use no letters except ‘a’ and ‘b’. ...

September 22, 2019 · 12 min · 2541 words · eonh1u

cf-edu-73

昨天参加了cf—edu-73 div2。嗯 很菜 以后有时间多参加一下cf,提一下rating。 A题 2048 Games: 题目: You are playing a variation of game 2048. Initially you have a multiset 𝑠 of 𝑛 integers. Every integer in this multiset is a power of two. You may perform any number (possibly, zero) operations with this multiset. During each operation you choose two equal integers from 𝑠, remove them from 𝑠 and insert the number equal to their sum into 𝑠. ...

September 19, 2019 · 9 min · 1721 words · eonh1u

51nod-1065-最小正字段和

题目: N个整数组成的序列a[1],a[2],a[3],…,a[n],从中选出一个子段(a[i],a[i+1],…a[j]),使这个子段的和>0,并且这个和是所有和>0的子序列中最小的。 例如:4,-1,5,-2,-1,2,6,-2。-1,5,-2,-1,序列和为1,是最小的。 输入 第1行:整数序列的长度N(2 <= N <= 50000) 第2 - N+1行:N个整数 输出 输出最小正子段和。 ...

September 18, 2019 · 1 min · 183 words · eonh1u

51nod-1919-炮兵阵地

题目: 司令部的将军们打算在N*N的网格地图上部署他们的炮兵部队。一个N*N的地图由N行N列组成,地图的每一格可能是山地(用"X"表示),也可能是平原(用".“表示)。在每一格平原地形上最多可以布置一支炮兵部队(山地上不能够部署炮兵部队);一支炮兵部队在地图上的攻击范围是它所在位置的对应的行和列,但是大炮打出去之后如果被山地阻挡 了,那么攻击范围就到那块山地。 ...

September 18, 2019 · 2 min · 254 words · eonh1u

51nod-1942-安装监控

题目: 现在要在办公室里面安装监控, 由于预算有限,现在只能安装一个摄像头,这个摄像头是可以360度旋转的。现在就要选择一个位置安装这个摄像头,使得它能够监控到办公室中的所有地方。办公室的边界以多边形给出,这个多边的所有边都是平行于座标轴的,并且不自交。 ...

September 17, 2019 · 1 min · 188 words · eonh1u

51nod-2488-矩形面积并的面积

题目: 在二维平面上,给定两个矩形,满足矩形的每条边分别和坐标轴平行,求这个两个矩形的并的面积。即它们重叠在一起之后的总的面积。 输入 8个数,分别表示第一个矩形左下角坐标为(A,B),右上角坐标为(C,D);第二个矩形左下角坐标为(E,F),右上角坐标为(G,H)。 保证A<C,B<D,E<G,F<H。 保证所有数的绝对值不超过2*10^9,矩形并的面积≤2*10^9。 ...

September 16, 2019 · 1 min · 139 words · eonh1u

51nod-1593-物理地址查询

题目: 在网络中,发送一个包需要知道对方的物理地址,当不知道物理地趣的时候,就要向网络中广播发送对方的IP地址,然后每一台计算会收到这个广播,如果IP和自己的计算对上,就把自己的物理地址发送出去。 现在有n台计算,编号从1到n,现在1号计算向网络中发送广播,问经过多少时间后所有的计算机都会收到这个广播。 输入的网络保证所有的计算机之间是可以相互通信的。 ...

September 12, 2019 · 2 min · 232 words · eonh1u