2019CCPC-江西省赛(重现赛)- 感谢南昌大学
趁著多校之際打了一下這個比賽,low的一批。做了七個題,被虐的不輕
Wave HDU - 6570
Avin is studying series. A series is called “wave” if the following conditions are satisfied:
You are given a series with length n. Avin asks you to find the longest “wave” subseries. A subseries is a subsequence of a series.
Input
The first line contains two numbers n, c (1 ≤ n ≤ 100, 000, 1 ≤ c ≤ 100). The second line contains n integers whose range is [1, c], which represents the series. It is guaranteed that there is always a “wave” subseries.
Output
Print the length of the longest “wave” subseries.
Sample Input
5 3
1 2 1 3 2
Sample Output
4
首先,n很大,1e5。但是我們發(fā)現(xiàn)這個c很小。我們可以把每個數(shù)的位置記錄下來,枚舉每兩個數(shù)他們出現(xiàn)的位置,復(fù)雜度不是很大。
代碼如下:
String HDU - 6572
Avin has a string. He would like to uniform-randomly select four characters (selecting the same character is allowed) from it. You are asked to calculate the probability of the four characters being ”avin” in order.
Input
The first line contains n (1 ≤ n ≤ 100), the length of the string. The second line contains the string. To simplify the problem, the characters of the string are from ’a’, ’v’, ’i’, ’n’.
Output
Print the reduced fraction (the greatest common divisor of the numerator and denominator is 1), representing the probability. If the answer is 0, you should output “0/1”.
Sample Input
4
avin
4
aaaa
Sample Output
1/256
0/1
很簡單的概率問題,數(shù)學(xué)純暴力
代碼如下:
Traffic HDU - 6573
Avin is observing the cars at a crossroads. He finds that there are n cars running in the east-west direction with the i-th car passing the intersection at time ai . There are another m cars running in the north-south direction with the i-th car passing the intersection at time bi . If two cars passing the intersections at the same time, a traffic crash occurs. In order to achieve world peace and harmony, all the cars running in the north-south direction wait the same amount of integral time so that no two cars bump. You are asked the minimum waiting time.
Input
The first line contains two integers n and m (1 ≤ n, m ≤ 1, 000). The second line contains n distinct integers ai (1 ≤ ai ≤ 1, 000). The third line contains m distinct integers bi (1 ≤ bi ≤ 1, 000).
Output
Print a non-negative integer denoting the minimum waiting time.
Sample Input
1 1
1
1
1 2
2
1 3
Sample Output
1
0
狗題,一開始讀錯題了,耽誤了好久。rng
直接枚舉等待的時間,讓南北向的車都等待,去判斷是否可行。
代碼如下:
Rng HDU - 6574
Avin is studying how to synthesize data. Given an integer n, he constructs an interval using the following method: he first generates a integer r between 1 and n (both inclusive) uniform-randomly, and then generates another integer l between 1 and r (both inclusive) uniform-randomly. The interval [l, r] is then constructed. Avin has constructed two intervals using the method above. He asks you what the probability that two intervals intersect is. You should print p* q(?1)(MOD 1, 000, 000, 007), while pq denoting the probability.
Input
Just one line contains the number n (1 ≤ n ≤ 1, 000, 000).
Output
Print the answer.
Sample Input
1
2
Sample Output
1
750000006
其實(shí)這個題就是瞎湊數(shù)。。。
寫了一個求逆元的找出n=2的時候,是3/4。又自己手算了一遍n=3的時候是2/3也就是4/6。在我算n=4的時候,隊(duì)友猜了一個結(jié)論交上去了就過了orz。
代碼如下:
Budget HDU - 6575
Avin’s company has many ongoing projects with different budgets. His company records the budgets using numbers rounded to 3 digits after the decimal place. However, the company is updating the system and all budgets will be rounded to 2 digits after the decimal place. For example, 1.004 will be rounded down
to 1.00 while 1.995 will be rounded up to 2.00. Avin wants to know the difference of the total budget caused by the update.
Input
The first line contains an integer n (1 ≤ n ≤ 1, 000). The second line contains n decimals, and the i-th decimal ai (0 ≤ ai ≤ 1e18) represents the budget of the i -th project. All decimals are rounded to 3 digits.
Output
Print the difference rounded to 3 digits…
Sample Input
1
1.001
1
0.999
2
1.001 0.999
Sample Output
-0.001
0.001
0.000
水題,但是還是錯了一發(fā),(讀錯題了rng)
代碼如下:
Worker HDU - 6576
Avin meets a rich customer today. He will earn 1 million dollars if he can solve a hard problem. There are n warehouses and m workers. Any worker in the i-th warehouse can handle ai orders per day. The customer wonders whether there exists one worker assignment method satisfying that every warehouse handles the same number of orders every day. Note that each worker should be assigned to exactly one warehouse and no worker is lazy when working.
Input
The first line contains two integers n (1 ≤ n ≤ 1, 000), m (1 ≤ m ≤ 1018). The second line contains n integers. The i-th integer ai (1 ≤ ai ≤ 10) represents one worker in the i-th warehouse can handle ai orders per day.
Output
If there is a feasible assignment method, print “Yes” in the first line. Then, in the second line, print n integers with the i-th integer representing the number of workers assigned to the i-th warehouse.
Otherwise, print “No” in one line. If there are multiple solutions, any solution is accepted.
Sample Input
2 6
1 2
2 5
1 2
Sample Output
Yes
4 2
No
提議挺簡單的,就是分配工人。但是一開始隊(duì)友最小公倍數(shù)求錯了。GG了。多個數(shù)的最小公倍數(shù)就是先求兩個數(shù)的最小公倍數(shù),然后再和第三個數(shù)求最小公倍數(shù),依次下去。
代碼如下:
Class HDU - 6577
Avin has two integers a, b (1 ≤ a, b ≤ 1, 000).
Given x = a + b and y = a - b, can you calculate ab?
Input
The first line contains two integers x, y.
Output
Print the result of ab.
Sample Input
4 2
Sample Output
3
水的不能再水的解方程
代碼如下:
A題的數(shù)據(jù)結(jié)構(gòu)題沒出出來。補(bǔ)完之后再發(fā)。
努力加油a啊,(o)/~
總結(jié)
以上是生活随笔為你收集整理的2019CCPC-江西省赛(重现赛)- 感谢南昌大学的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 1103: [POI2007]大都市me
- 下一篇: Codeforces Round #57