http://acm.hdu.edu.cn/showproblem.php?pid=1018Test instructions: Gives a number n, the number of bits of the factorial of the output nKhan Σ (° °| | |) ︴At first, we were prepared to multiply the multiplication of large numbers, but the factorial result of 10000 was nearly 40,000.The factorial of 10^7 ...Positive: For a number n the number of bits can be calculated with LOG10 (n) + 1So for n! The number of digits = log10 (1*2*...* (N-1) *n) +1 = log10 (1) +log10 (2) +: +LOG10 (N-1) +log10 (N) +
Topic Link: Click to open the linkSterling Number: Click to open linkTest instructions is calculated n! The number of digitsThat is, ans = log10 (n!) = log10 (sqrt (2πn)) + N*LOG10 (n/e)#include HDU 1018 Big number Stirling approximate n!
sterling formula is very useful, and even when N is very small, the value of the sterling formula is very accurate. Stirling Formula:But only with this formula is not enough, because the factorial of N to more than 10 of the super int range, this question to calculate n! factorial of the number of bits, for a number A, if there is 10^ (x-1) 1#include 2#include 3 using namespacestd;4 5 intMain ()6 {7 intn,m;8 Doubles;9Cin>>N;Ten while(n--) One { As=0.0; -Cin>>m; - if(m
the program:The first line has a total of 2 natural numbers n,k (6≤n≤40,1≤k≤6)The second line is a number string with a length of N.Output format:The result is displayed on the screen, and the maximum product (a natural number) should be output relative to the input.Input/Output sampleInput Sample # #:4 21231Sample # # of output:62DescriptionThe second problem of NOIp2000 raising groupThinking of solving problemsDP,F[I,J] Indicates the maximum product of J multiplication Sign in the number of
is X-1Then (int) log10 (a) =x-1,i.e. (int) log10 (a) +1=xThat is, the number of bits of a is (int) log10 (a) +1We know that a positive integer A has a number of digits equal to (int) log10 (a) + 1,Now to find the number of bits of the factorial of N:Assuming a=n!=1*2*3*......*n, then what we're asking for IS(int) log10 (A) +1, while:LOG10 (A)=LOG10 (1*2*3*......N) (according to log10 (a*b) = log10 (a) + log10 (b) Yes)=LOG10 (1) +log10 (2) +log10 (3) +......+log10 (n)Now that we finally find the
Problem DescriptionIn Many applications very large integers numbers are required. Some of these applications is using keys for secure transmission of data, encryption, etc.In this problem you is given a number, you has to determine the number of digits in the factorial of the number. Inputinput consists of several lines of integer numbers. The first line contains a integer n, which is the number of cases to being tested, followed by n lines, one integer 1≤n≤107 on all line.Outputthe output conta
... If we ask for the connectivity of [L, R] City (i.e. [L, r-1] lattice, assuming that the lattice numbering starts from 1 to the left to the right), then you can use something to maintain the entire interval of the lattice, the answer is the entire interval boundary of the 4 points of connectivity .... Found that is not all very similar, that is, multiple grids and a lattice are to take the boundary of the 4 points to judge .... And [L, R-1] can be combined by ... So on the line segment tree
Big numberThis problem, there is no difficulty or anything, is to rise posture. Problem DescriptionIn Many applications very large integers numbers are required. Some of these applications is using keys for secure transmission of data, encryption, etc. In this problem you is given a number, you has to determine the number of digits in the factorial of the number.Inputinput consists of several lines of integer numbers. The first line contains a integer n, which is the number of cases to being tes
[Neuqacm oj] 1018: A + B again, neuqacmoj1018: A + B again Title Description
Gu xuecang has A very simple question for you. Here are two integers A and B. Your task is to calculate A + B.Input
The first line of the input contains an integer T (T Output
For each example, you should output two rows. The first row is "Case #:", # indicates the first few examples, the second row is an equation "A + B = Sum". Sum indicates the result of A + B. Note that th
gives n integers, sorts n integersInputLine 1th: number of integers n (1 OutputA total of n rows to output sorted data in ascending order.Input example554321Output example12345Sort from big to small1#include 2 using namespacestd;3 inta[50050];4 intMain () {5 intN;6scanf"%d",N); 7Memset (A,0,sizeof(a)); 8 for(intI=0; i)9scanf"%d",a[i]);TenSort (a,a+n); One for(intI=0; i) Aprintf"%d\n", A[i]); - return 0; -}51nod 1018 Sort
Meaning
A two-fork tree with a value for the edge, and the node number is 1~n,1 is the root node. To cut off some of the edges, just keep the Q-side, the Q-Edge of the subtree
The root node requirement is 1, ask what is the maximum weight of this subtree?
Ideas
A very classic tree-type DP problem, according to my current problem, there are many ways are derived from this problem.
F (I, j) represents the subtree I, preserving the maximum weight of the J node (note is the node). The weight of
Url-1018 to give a edge of the value of the Binary Tree, node number is 1 ~ N, 1 is the root node. Cut down some edges and keep only q edges. The root node of the subtree composed of q edges must be 1. What is the maximum weight of this subtree? The idea is a classic tree dp question. According to the questions I have done so far, many of them are derived from this question. F (I, j) indicates subtree I, and retains the maximum weight of j nodes (note
Topic 1018: Statistics on the number of students with gradestime limit:1 secondsMemory limit:32 MBSpecial question: Nosubmitted:10803Resolution:5662
Title Description:
reading the scores of n students, the number of students will be output for a given score.
Input:
The test input contains several test cases, each of which is in the format
Line 1th: N
Line 2nd: The
1018: [SHOI2008] blocked traffic traffic time
limit: 3 Sec
Memory Limit: 162 MB
Submit: 1811
Solved: 580
[Submit] [Status]
DescriptionOne day, because of some kind of cross-over phenomenon, you came to the legendary small country. The layout of the small country is very peculiar, the whole country's transportation system can be regarded as a 2 row C-column rectangular grid, each point on the grid represents a city, there is
1018. Hammer and Scissors cloth (20)Everyone should play "Hammer and Scissors Cloth" game: two people at the same time give gestures, the rule of victory:
Now give a record of the confrontation between two people, please count the wins, flat, negative number of both sides, and give the two sides what gesture of the greatest odds.Input format:Enter line 1th to give the positive integer n (Output format:Output 1th, 2 respectively give a, B wins, f
1018. Binary Apple Treetime limit:1.0 SecondMemory limit:64 Mblet ' s Imagine how apple tree looks in binary computer world. You're right, it's looks just like a binary tree, i.e. any biparous branch splits up to exactly, and new branches. We'll enumerate by integers the root of the binary Apple tree, points of branching and the ends of twigs. This is the distinguish different branches by their ending points. We'll assume that root of the tree always
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.