Sterling Formula-stirling formula (take n factorial approximation)-hdu1018-big number Cattle Network Nowcoder 2018 National multi-school algorithm winter Camp Practice competition (third session) A. Uncommon Husband

Source: Internet
Author: User
Tags acos integer numbers cmath

Recently a pile of questions to fill, has been salted fish, fill a pile of water problems are not necessary to write a problem. Forget about this formula.

The meaning of the Stirling formula is that when n is large enough, n! is very difficult to calculate, although there are many equations about n!, but it is not very good to estimate factorial results, especially after N is large, the error will be very large. However, the Stirling formula can be used to transform factorial into power function, so that the result of factorial is better estimated. and the larger the N, the more accurate the estimate.

Portal: _ (: З"∠) _

One more detail, Portal: (? ′ω '? )

Two more questions.

HDU1018

Big Number

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 40645 Accepted Submission (s): 19863


problem DescriptionIn many applications very large integers numbers is 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 contains the number of digits in the factorial of the integers appearing in the input.

Sample Input21020

Sample Output719

SourceAsia 2002, Dhaka (Bengal) code:
1#include <iostream>2#include <cstring>3#include <cstdio>4#include <algorithm>5#include <cmath>6 using namespacestd;7 Const DoubleE=exp (1);8 Const DoublePi=acos (-1.0);9 intMain () {Ten     intT; Onescanf"%d",&t); A      while(t--){ -         intN; -scanf"%d",&n); the         if(n==1) {printf ("1\n");Continue;} -         DoubleS=LOG10 (2.0*PI)/2.0+ (n+0.5) *log10 (n)-n*log10 (e); -         intans=Ceil (s); -printf"%d\n", ans); +     } -     return 0; +}

2018 National multi-school algorithm winter training Camp Practice competition (third session) A. The Uncommon husbandtime limit: C/s 1 sec, other languages 2 seconds
Space Limitations: C/C + + 32768K, other languages 65536K
64bit IO Format:%lld
Links:Https://www.nowcoder.net/acm/contest/75/A
Source: Niu Ke netTopic Description The husband is interested in a number of digits one day, but he doesn't want to be like a man,
So he wanted to know to give an integer n, beg n! The number of bits in the 8 binary. Input Description:
The first line is an integer t (0<t<=1000000) (representing the T-group data)
Next T line, each line has an integer n (0<=n<=10000000)
Output Description:
Output n! The number of digits in the 8 binary.
Example 1 input
3425
Output
213



Code:
1 //A-Sterling formula-to find the number of digits2#include <iostream>3#include <cstring>4#include <cstdio>5#include <cmath>6#include <algorithm>7#include <stack>8#include <map>9#include <vector>Ten#include <queue> One#include <Set> A using namespacestd; - Const intinf=1<< -; - Const intmaxn=1e5+Ten; the Const Doubleeps=1e-6; - Const intmod=1e9+7; - Const DoublePi=acos (-1.0); - Const Doubleepx=1e-Ten; + Const DoubleE=exp (1); -typedefLong Longll; + intLintN) { A     ints=1; at     if(n>3) -s= (log (2*pi*n)/log (8))/2+n* (log (n/e)/log (8))+1; -     returns; - } - intMain () { -     intn,t; inscanf"%d",&t); -      while(t--){ toscanf"%d",&n); +printf"%d\n", L (n)); -     } the     return 0; *}


Recently a pile of large number of topics written in the head are fried, Java Science Super Garbage, C language version too long do not want to write ...

Supplementary questions, the sinkhole has not been mended ...

It's so rubbish, I don't know how to cook.

Sterling Formula-stirling formula (take n factorial approximation)-hdu1018-big number Cattle Network Nowcoder 2018 National multi-school algorithm winter Camp Practice competition (third session) A. Uncommon Husband

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.