HDU 4985 little pony and Permutation
Question Link
Question: Given a replacement, the output is decomposed into loops.
Water questions, directly simulate
Code:
#include
HDU 4985 little pony and permutation (replacement)
Question link: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 4986
Meaning: There are n boxes (numbers from left to right are 1 ~ N), each box has a random key. It is possible that this key can be opened to this box, but in most cases it cannot. Ask the expected value. (For example, for two boxes, the key may contain 1 2 or 2 1. If it is 1 2, you need to use two spells, for 2 1 (open one box to get the key to open another box), you only need to use it once. The expected value is 1/2*2 + 1/2*1 =
Test instructions: N-face Dice throw m times, to find the maximum value of expectations.Other people's practice: probability of maximum i = probability of all points SB procedure: The accuracy requirement 1e-4, and M large when the maximum is a small number of probability is very small, the accuracy range does not affect the answer, so direct dp,f[i][j] means the probability of the maximum value of J after the throw I, through the prefix and optimization to do O (n) transferEquation is f[i][j]=
Let's take a look at what everyone knows:
When I went home this week, I saw my sister's computer had a trojan virus. It was miserable. When I checked the taskbar, 360 of the security guards and the virus were gone. The first thing was immediately installed. What's worse, other Websites can access, but the 360 Homepage cannot be accessed (this is also suspended). I rely on it. Forget it. I went to other websites and got 360 security guards and Antivirus services. Of course, all the Trojans and
Recurrence. Set the number of spell times for N boxes to S (n), and the expected number is E (n ).When there are n boxes, the nth key may be in the nth box. The number of spell times should be (n-1 )! + S (n-1 );When the n-th key is not in the n-th box, the number of spell times is (n-1) * s (n-1 ),Therefore, we expect E (n) = S (n)/n !, S (n) = (n-1 )! + S (n-1) + (n-1) * s (n-1) = (n-1 )! + N * s (n-1 ),Then E (n) = S (n-1)/(n-1 )! + 1/N = E (n-1) + 1/N.Therefore, the recursive formula E (n) =
get 1 in the first toss, and 1 in the second. Maximum equals to 1.
You can get 2 in the first toss, and 1 in the second. Maximum equals to 2.
You can get 2 in the first toss, and 2 in the second. Maximum equals to 2.
The probability of each outcome are 0.25, that's expectation equals to:
You can read about expectation using the following link: http://en.wikipedia.org/wiki/Expected_value/* for a number I he appears as many times as I^m-(i-1) ^m (1^m-0^m) + ... + (I^m-(i-1)
structure (more practical, there are n functions called this method, modified once done)Alt+shift+l extract Local variables (you can directly extract some magical numbers and strings into a variable, especially when multiple calls are made)Alt+shift+f change the local variable in class to a field variable (more useful function)Alt+shift+i Merge variables (this may be a bit inappropriate inline)ALT+SHIFT+V moving functions and variables (not commonly used)Alt+shift+z reconstruction of Regret med
Hadoop exception and handling Summary-01 (pony-original), hadoop-01
Test environment:
Local: MyEclipse
Cluster: Vmware 11 + 6 Centos 6.5
Hadoop version: 2.4.0 (configured as automatic HA)
Test Background:
After four normal tests of the MapReduce Program (hereinafter referred to as MapReduce), a new MR program is executed, and the console information of MyEclipse is stuck, I remotely connect to NameNode to view the system directory. At this time, I lo
Sharing of pony php bypass dongle DetectionDirectly run the Code:
Analysis and Exploitation Overhead:
Usage:
Encode the written content with a url, such as Encoded as: % 3C % 3F % 70% 68% 70% 20% 70% 68% 70% 69% 6E % 66% 6F % 28% 29% 3B % 3F % 3E
Remove % and get 3C3F70687020706870696E666F28293B3F3E.
Then access the backdoor and change the POST content:
A =/111.php B = 3C3F70687020706870696E666F28293B3F3E
You can write content.
Ov
Test instructions: A sieve has M faces, and then throws N times, seeking the maximum value of the expectation;Idea: The maximum value is 1 There are 1 kinds, 2 have 2n-1 species, 3 have 3n-2n species, so for M when there is MN-(m-1) n species, so each one of the probabilities, and then multiplied by the sum of this value can be.1#include 2#include 3#include 4#include 5#include 6 using namespacestd;7 8 intn,m;9 Ten intMain () One { ACin>>m>>N; - DoubleX=pow (1.0/m,n); - Doubleans=x; the
Test instructionsAsk for a four-sided Fermat point.Analysis:Simulated annealing either timed out or WA, the data of this problem is not want to let random algorithm over. In fact, the four-sided Fermat point is very simple, if it is convex four-sided call horse point is the diagonal intersection, if the concave quadrilateral cost horse point is a concave point. However, the four point order given by the topic is indeterminate, so the convex hull must be obtained first.Code:POJ 3990//sep9#include
Link: codeforces 453 little pony and Summer Sun Celebration
N nodes, m edges, and m rows are given a fixed edge. The last line indicates the number of times each node needs to enter is an odd or even number of times.
Solution: Construct a structure that can start from an odd point (Unified forest processing), traverse the nodes that have not passed through each time, and trace back, every time you trace back, you need to judge whether the point you ju
Question Link
Question: I threw a dice on the m Plane n times and expected the maximum value.
Idea: mathematical expectation. The formula for discretization is E (x) = x1 * P (X1) + x2 * P (X2) + ...... + Xn * P (Xn)
P (xi) indicates the number of all cases where the maximum value is XI/The total number of cases is m ^ N, throwing n times, the number of all cases where the maximum value is XI should be Xi ^ N, but the maximum value is not XI and cannot exceed Xi, so subtract the maximum value is
Codeforces Round #259 (Div. 2) B. Little Pony and Sort by Shift,
Link: http://codeforces.com/contest/454/problem/ B
Problem-solving ideas: we only need to judge a few a [I]
# Include
Codeforces #259 DIV2 C question Little Pony and Expected Maximum (exclusion + Rapid power + formula derivation ),
Address: http://codeforces.com/contest/454/problem/C
According to the principle of rejection, a formula can be provided:
Expected P = (m ^ n-(m-1) ^ n) * m + (m-1) ^ n-(m-2) ^ n) * m-1) + ....... + (1 ^ n-0 ^ n) * 1)/m ^ n;
This formula can be easily introduced .. The power from 1 to m can be obtained using a fast power. But one problem is
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.