A stock’s price fluctuates every day by going up exactly 5% or going down exactly 5%. Assume that each direction is equally likely. Assume zero trading cost, zero interest rate, and no dividends and splits. What strategy is most likely to be profitable after 100 days?
(3 min, score = 3)
A. Buy or sell will produce same profitable
B. Cannot know / no strategy can be profitable
C. Buy the stock
D. Sell the stock
Solution:
D
Below is a list of asymptotic complexities of 8 functions, each with length N input:
O(N^3)
O(Log(N))
O(Sqrt(N))
O(N * log(N))
O(2^N)
O(N^N)
O(N!)
O(Log(Log(N)))
Please sort the functions by order of growth, with slower growing functions first. (your answer shall be a sequence of letters, for example “BACDFHGE”)
(4 min, score = 3)
Solution:
HBDCAEGF
What is the maximum possible variance of a random variable taking values in the interval [0, 10]?
(2 min, score = 2)
Solution:
Half is 0, half is 10.
Var(x)=E[X−E(X)]2=52=25
How many integers n such that nn is a perfect square are there in range [100: 400]?
(5 min, score = 4)
Solution:
If n is even, n=2k, then √nn=√n2k=nk, so it’s a perfect square.
If n is odd, n=2k+1, then √nn=√n2k+1=nk√n, it’s a perfect square if and only if n is a perfect square.
We have:
102=100202=400
So there are 5 odds that meet the condition, 112,132,…,192.
Totally, 151+5=156 integers.
Assume there are three random variables X,Y,Z. All pairwise correlations are equal: corr(x,y)=corr(y,z)=corr(x,z)=r. What is the range of possible values of r? (list a range, like [−0.3:0.7], for example)
(6 min, score = 12)
Assume there are three random variables X,Y,Z. We would like to use one number to describe their relations, just like the pairwise correlation of 2 variables corr(x,y). We need the number to be normalized. Please list the possible mathematical formulas to calculate such number, the more the better.
(6 min, score = 12)
Solution:
3corr(x,y)+corr(y,z)+corr(x,z)
Triangle ABC has sides of length 45, 60 and 75. A point X is placed randomly and uniformly inside the triangle. What is the expected value of the sum of perpendicular distance from point X to this triangle’s three sides?
(9 min, score = 10)
Solution:
452+602=752
It’s easy to know, triangle ABC is a right triangle.
Please list one of your most “strange” or “crazy” idea to predict stock’s return. You can assume you have all available public data and strong computing power. The answer shall be as “strange” as possible.
(6 min, score = 10)
Solution:
Use the stock code to select stocks. If the stock code is a prime number, buy it and hold. The strategy is pretty strange because there should be no useful information in the stock code.
表明转换了T(⋅) 的输入 x 然后传递它到层次Φ(⋅)的网络(即得到Tx后再用网络作用)应该有同样的结果在第一次用网络映射x然后再转换表示(即先得到Φ(x),再用T作用)。注意:T′(⋅)和T(⋅)不是必须相同的。根据这个理论,应用转换层或者滤波器Φ(⋅)去压缩整个网络模型是合理的。从经验观察,深度CNNs同样受益于使用大的卷积滤波器通过应用确定的转换T(⋅)到一个小的基础偏置滤波器的集合,由于它扮演了一个模型的正则化。
import torch import torch.nn as nn import torch.nn.functional as F
classIdentify(nn.Module): def__init__(self): super().__init__() defforward(self, x): return x
classL2Normalization(nn.Module): def__init__(self, p=2, dim=-1): super().__init__() self.p = p self.dim = dim defforward(self, x): out = F.normalize(x, p=2, dim=-1) return out
classGlobalDescriptor(nn.Module): def__init__(self, pooling_type, trainable=False): super().__init__() if trainable: self.p = nn.Parameter(torch.tensor([3.])) else: self.p = 3 if pooling_type == 's': self.method = nn.AdaptiveAvgPool2d(1) elif pooling_type == 'm': self.method = nn.AdaptiveMaxPool2d(1) else: defGeM(x): mean_value = torch.mean(torch.pow(x, self.p), dim=[-1, -2], keepdim=True) out = torch.sign(mean_value) * torch.pow(torch.abs(mean_value), 1 / self.p) return out self.method = GeM self.flatten = nn.Flatten() defforward(self, x): out = self.method(x) out = self.flatten(out) return out
Arthur owns a ski resort on a mountain. There are n landing spots on the mountain numbered from 1 to n from the top to the foot of the mountain. The spots are connected with one-directional ski tracks. All tracks go towards the foot of the mountain, so there are no directed cycles formed by the tracks. There are at most two tracks leaving each spot, but many tracks may enter the same spot.
A skier can start skiing from one spot and stop in another spot if there is a sequence of tracks that lead from the starting spot and end in the ending spot. Unfortunately, recently there were many accidents, because the structure of the resort allows a skier to go through dangerous paths, by reaching high speed and endangering himself and the other customers. Here, a path is called dangerous, if it consists of at least two tracks.
Arthur wants to secure his customers by closing some of the spots in a way that there are no dangerous paths in the resort. When a spot is closed, all tracks entering and leaving that spot become unusable.
Formally, after closing some of the spots, there should not be a path that consists of two or more tracks.
Arthur doesn’t want to close too many spots. He will be happy to find any way to close at most 74n spots so that the remaining part is safe. Help him find any suitable way to do so.
Input
The first line contains a single positive integer T — the number of test cases. T test case description follows.
The first line of each description contains two integers n and m (1≤n≤2⋅105) — the number of landing spots and tracks respectively.
The following m lines describe the tracks. Each of these lines contains two integers x and y (1≤x<y≤n) — indices of the starting and finishing spots for the respective track. It is guaranteed that at most two tracks start at each spot. There may be tracks in which starting and finishing spots both coincide.
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105.
Output
For each test case, print a single integer k (0≤k≤74n) — the number of spots to be closed. In the next line, print k distinct integers — indices of all spots to be closed, in any order.
If there are several answers, you may output any of them. Note that you don’t have to minimize k. It can be shown that a suitable answer always exists.