POJ 1423 Big Number

题目连接:http://poj.org/problem?id=1423

#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int a[10000001];
int main()
{   //freopen("in.txt","r",stdin);
    int n,i,t,m;
    double sum;
    for(i=1;i<=10000000;i++)//打表,开始忘记了,果断TLT,得长记性!
    {
        sum+=log10(double(i));
        a[i]=sum+1;
    }
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        printf("%d\n",a[n]);
    }
    return 0;
}

posted on 2012-03-30 09:35  江财小子  阅读(116)  评论(0编辑  收藏  举报