Big Number(简单数学题)

Big Number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 26003    Accepted Submission(s): 11810

Problem Description

In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of
digits in the factorial of the number.

Input

Input consists of several lines of integer numbers. The first line contains an integer n, which is the number of cases to be tested, followed by n lines, one integer 1 ≤ n ≤ 107 on each line.

Output

The output contains the number of digits in the factorial of the integers appearing in the input.

Sample Input

2
10
20

Sample Output

7
19

Source

Asia 2002, Dhaka (Bengal)

意解:用对数来求n的阶乘的位数;

AC代码:

#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

using namespace std;
typedef long long ll;

int main()
{
    int n,m;
    cin>>m;
    while(m--)
    {
        scanf("%d",&n);
        double sum = 0;
        for(int i = 1; i <= n; i++)
        {
            sum += log10((double)i);
        }
        printf("%d\n",(int)sum + 1);
    }
    return 0;
}
时间: 2024-10-18 12:47:05

Big Number(简单数学题)的相关文章

poj 3117 World Cup(简单数学题)

题目链接:http://poj.org/problem?id=3117 World Cup Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8634   Accepted: 4327 Description A World Cup of association football is being held with teams from around the world. The standing is based on

hdu 2368 Alfredo&#39;s Pizza Restaurant(简单数学题)

转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2368 题目很简单,但是比较恶心,用sqrt WA到死也不过,不用秒过: 忍不住吐槽一下; Problem Description Traditionally after the Local Contest, judges and contestants go to their favourite restaurant,

hdu2374 A Game with Marbles(简单数学题)

转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2374 Problem Description There are n bowls, numbered from 1 to n. Initially, bowl i contains mi marbles. One game step consists of removing one marble from a bowl.

Codeforces Round #262 (Div. 2)460A. Vasya and Socks(简单数学题)

题目链接:http://codeforces.com/contest/460/problem/A A. Vasya and Socks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya has n pairs of socks. In the morning of each day Vasya has to put o

UVA 12714 Two Points Revisited(简单数学题)

转载请注明出处:http://blog.csdn.net/u012860063 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4452 题意: 给出两个点组成一条直线,要你任意输出两个点,要求这两点组成的直线和给出的直线垂直(注意输出的点不能有负数): 代码如下: #include <cstdio> int main(

hdu 4937 Lucky Number(数学题 进制转换)2014多校训练第7场

Lucky Number                                                                          Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description "Ladies and Gentlemen, It's show time! " "A thie

HDU 1018 Big Number (简单数学)

Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 25649    Accepted Submission(s): 11635 Problem Description In many applications very large integers numbers are required. Some of these

HDU 1018 Big Number (数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1018 解题报告:输入一个n,求n!有多少位. 首先任意一个数 x 的位数 = (int)log10(x) + 1; 所以n!的位数 = (int)log10(1*2*3*.......n) + 1; = (int)(log10(1) + log10(2) + log10(3) + ........ log10(n)) + 1; 1 #include<cstdio> 2 #include<cs

JZOJ5773 简单数学题

escription 话说, 小X是个数学大佬,他喜欢做数学题.有一天,小X想考一考小Y.他问了小Y一道数学题.题目如下: 对于一个正整数N,存在一个正整数T(0<T<N),使得的值是正整数. 小X给出N,让小Y给出所有可能的T.如果小Y不回答这个神奇的大佬的简单数学题,他学神的形象就会支离破碎.所以小Y求你帮他回答小X的问题. Input  一个整数N. Output 第一个数M,表示对于正整数N,存在M个不同的正整数T,使得是整数. 后面是M个数,每一个数代表可能的正整数T(按从小到大的顺

HDU 6467 简单数学题 【递推公式 &amp;&amp; O(1)优化乘法】(广东工业大学第十四届程序设计竞赛)

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6467 简单数学题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 308    Accepted Submission(s): 150 Problem Description 已知 F(n)=∑i=1n(i×∑j=inCij) 求 F(n) m