Wednesday, 30 September 2015

UVA 1185 Big Number (UVALive 2697, HDU 1018, POJ 1423, ZOJ 1526, SCU 3094, Regionals 2002 >> Asia - Dhaka)

#include<bits/stdc++.h>
using namespace std;

#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
#define PI acos(-1.0)

#define MOD 1000000007
#define MX 100010

double digit[10000000+10];

void precal()
{
    digit[1]=log10(1);
    for(int i=2;i<=10000000;i++)
        digit[i]=digit[i-1]+log10(i);
return;
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    int n, tc;
    precal();
    cin>>tc;
    while(tc--)
    {
        cin>>n;
        cout<<(int)digit[n]+1<<"\n";
    }
return 0;
}

No comments:

Post a Comment