Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

打个小表就行了嘛

Posted by nimohunter at 2014-08-04 11:19:52 on Problem 1423
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator