Thursday, June 23, 2016

UVA 1185

#include<bits/stdc++.h>

using namespace std;

int DP[10000001] = {0};

int main() {
 
 int t, n, i;
 double last = 0;
 
 for(i = 1; i <= 10000000; i++) {
  last += log10(i);
  DP[i] = (int)last;
 }
 
 scanf("%d", &t);
 
 while(t--) {
  scanf("%d", &n);
  printf("%d\n",DP[n]+1);
 }
 
    return 0;
} 

No comments:

Post a Comment

Thank you for commenting. Please wait for response :)