| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
打个小表就行了嘛#include <cstdio>
#include <cmath>
using namespace std;
const int nimo[10] = {0, 5565709, 11733475, 18128484, 24671066, 31323382, 38063145, 44875629, 51750368, 58679537};
const int num[10] = {0, 1000000,2000000,3000000,4000000,5000000,6000000,7000000,8000000,9000000};
int main()
{
//freopen("nimo.in", "r", stdin);
int cas, n;
scanf("%d", &cas);
while (cas--)
{
scanf("%d", &n);
double ans;
int st;
for (int i = 9; i >= 0; i--)
if (n > num[i])
{
ans = nimo[i];
st = num[i] + 1;
break;
}
for (int i = st; i <= n; i++)
ans += log10(i);
printf("%d\n", (int)ans + 1);
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator