题目链接:点击打开链接
A. Mishka and Game
time limit per test
memory limit per test
input
output
Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in a wonderful sunny morning, walking around blocks of ice, Mishka met her friend Chris, and they started playing the game.
n is defined. In every round each of the players throws a cubical dice with distinct numbers from 1 to 6
In average, player, who won most of the rounds, is the winner of the game. In case if two players won the same number of rounds, the result of the game is draw.
Mishka is still very little and can't count wins and losses, so she asked you to watch their game and determine its result. Please help her!
Input
n n (1 ≤ n ≤ 100) — the number of game rounds.
n lines contains rounds description. i-th of them contains pair of integers m and ci (1 ≤ mi, ci) — values on dice upper face after Mishka's and Chris' throws in i-th round respectively.
Output
"Mishka"
"Chris"
"Friendship is magic!^^"
Examples
input
3 3 5 2 1 4 2
output
Mishka
input
2 6 1 1 6
output
Friendship is magic!^^
input
3 1 5 3 3 2 2
output
Chris
Note
In the first sample case Mishka loses the first round, but wins second and third rounds and thus she is the winner of the game.
In the second sample case Mishka wins the first round, Chris wins the second round, and the game ends with draw with score 1:1.
In the third sample case Chris wins the first round, but there is no winner of the next two rounds. The winner of the game is Chris.
题意:就是两个人掷色子比大小
题目链接:点击打开链接
B. Mishka and trip
time limit per test
memory limit per test
input
output
Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country.
Here are some interesting facts about XXX:
- ncities,k
- i-th city equals toci.
- 1-st andn-th city, forming a cyclic route 1 — 2 — ... —n— 1. Formally, for every 1 ≤i<nthere is a road betweeni-th andi+ 1-th city, and another one between 1-st andn-th city.
- xis a capital city, then for every1 ≤i≤n,i≠x, there is a road between citiesxandi.
- at most one
- iandj, price of passing it equalsci·cj.
each of the roads in XXX. Formally, for every pair of cities a and b (a < b), such that there is a road betweena and b you are to find sum of products ca·cb. Will you help her?
Input
n and k (3 ≤ n ≤ 100 000, 1 ≤ k ≤ n) — the number of cities in XXX and the number of capital cities among them.
n integers c1, c2, ..., cn (1 ≤ ci) — beauty values of the cities.
k distinct integers id1, id2, ..., idk (1 ≤ idi ≤ n) — indices of capital cities. Indices are given in ascending order.
Output
Print the only integer — summary price of passing each of the roads in XXX.
input
4 1 2 3 1 2 3
output
17
input
5 2 3 5 2 2 4 1 4
output
71
Note
This image describes first sample case:
17.
This image describes second sample case:
71.
题意:有n个城市,普通城市会和下一个城市有一条连线,省会城市 会与其他所有城市都有一条边,边的权值是两个城市权值的乘积,求所有边的权值之和!
思路:如第二个样例吧,省会城市有1和4,那么先算1相连的,用分配律计算是:a1*a2 + a1*a3 + a1*a4+a1*a5 = a1*T�n�qO �+a4+a5)所以可以先预处理一个权值之和,第一个城市相连边权值之和就是 (sum - a[1]) * a[1];计算城市4,计算要减去重复的,计算式是 (sum-a[1]-a[4])*a[4] 这就是规律了。这样算完后,会发现城市2还没有访问,所以可以在遍历一遍n个城市,找出未访问的城市,加上它即可
题目链接:点击打开链接
C. Chris and Road
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
And while Mishka is enjoying her trip...
Chris is a little brown bear. No one knows, where and when he met Mishka, but for a long time they are together (excluding her current trip). However, best friends are important too. John is Chris' best friend.
Once walking with his friend, John gave Chris the following problem:
At the infinite horizontal road of width w, bounded by lines y and y = w, there is a bus moving, presented as a convex polygon of nvertices. The bus moves continuously with a constant speed of v in a straight Ox line in direction of decreasing x coordinates, thus in time only x of its points are changing. Formally, after time t each of x coordinates of its points will be decreased by vt.
There is a pedestrian in the point (0, 0), who can move only by a vertical pedestrian crossing, presented as a segment connecting points(0, 0) and (0, w) with any speed not exceeding u. Thus the pedestrian can move only in a straight line Oy in any direction with any speed not exceeding u
Please look at the sample note picture for better understanding.
We consider the pedestrian is hit by the bus, if at any moment the point he is located in lies strictly inside
You are given the bus position at the moment 0. Please help Chris determine minimum amount of time the pedestrian needs to cross the road and reach the point (0, w)
Input
The first line of the input contains four integers n, w, v, u (3 ≤ n, 1 ≤ w ≤ 109, 1 ≤ v, u) — the number of the bus polygon vertices, road width, bus speed and pedestrian speed respectively.
The next n lines describes polygon vertices in counter-clockwise order. i-th of them contains pair of integers xi and yi (9 ≤ xi ≤ 109,0 ≤ yi ≤ w) — coordinates of i-th polygon point. It is guaranteed that the polygon is non-degenerate.
Output
Print the single real t — the time the pedestrian needs to croos the road and not to be hit by the bus. The answer is considered correct if its relative or absolute error doesn't exceed 10 - 6.
Example
input
output
5.0000000000
Note
Following image describes initial position in the first sample case:
这题开始以为很麻烦;看了别人的思路恍然大悟
题解:一共有三种情况:
①. 人以最大速度u前进时,汽车的速度很慢,任意一点都到达不了人的位置
②.人以最大速度u前行时,汽车的速度很快,在人达到之前汽车的任意一点都已经通过了y轴
③.人以最大速度u前进时,会与汽车相撞,需要调整速度躲避汽车
上面三种情况,①②两种都可以直接以最大速度u通过马路。对于第③种情况,我们可以在汽车最后一个通过y轴的点通过时行人恰好到达那个点的位置(如上图就是(0,3)),然后全速u走到终点。在过这个点之前,行人怎么变速的,我们就没必要考虑,反正他到达这个点的时间就是汽车完全通过这个点的时间,这样想来就好多了