Long time did not write the solution of the problem, a lot of good feeling did not leave any questions so later, anxious to change the question a lot of details and principles have not noticed, it is not enough to think (the test was getting worse), so it is necessary to write .
A. math
After seeing nothing really accepted the idea of complexity. Direct that practice it.
70%: O (nk ^ 2)
Each of the A I as a group, a (ai * bi)% k most k known article (circular section) of each group, then the problem is transformed into a packet backpack, to see how many <can be non-negative integer k is Couchu.
Due to the long cycle section less than k, so it lured 70 points. . .
70% of O (nklogk)
Observed on the face of each item must traverse a capacity, and a lot of capacity is useless state. The most obvious, for a group of articles, in fact, is to put an item repeated many times and counted as one.
Then we can find no use packet, defined as the weight of a single item value ai, ai is the number of k in the sense die can take the number of values, i.e., the length of loop section.
Then the multiple backpack can be optimized binary.
80%: O (nk)
Found a Couchu capacity will be repeated many times.
Down on mold k sense, the answer up to the k. Set DP [k] is a k can be Couchu, then the search is repeated using the n-th article can expand to a new state.
100%:O(n+k)
In fact, from a given sample can see the answer is the arithmetic series, yy can find gcd about tolerance and k is ai
Then the AC. . . . . .
On the test can not tell me this amount. . .
Correctness:
ax + by = c (mod k) has a solution if and only if integer d | c,
Then ax + by + cz + .... = q (mod k) has an integer solution if and only if gcd (a, b, c, ...) | q
Shu Pei is actually inference theorem.
B. biology
When the examination have been thinking about graph theory, then finally hit the topology of a n ^ 2m ^ 2 ran. . .
Then I thought DAG topology is not dp it. . .
Topology optimization but no way can dp
40%:O(n^2m^2)朴素dp:f[i][j]=max(f[k][l]+b[i][j]+|i-k|+|j-l|)
80%: O (nmlognlogm)
Persimmon routine encounter absolute value to open
Then you can use the four-dimensional Fenwick tree maintenance.
100%:
Chebyshev distance
First look pigeon