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 liangyifeng_rjxy at 2007-09-09 10:03:26 on Problem 3331
一定要把N!结果算出来才可以么?
#include <stdio.h>

int main()
{
	int t,b,p,j,i,temp,jw,dl;
	int d[780];
	scanf("%d",&t);
	while(t--)
	{
			d[1]=1;
			dl=1;
		scanf("%d %d",&b,&p);
		for(i=1;i<=b;i++)
		{
			jw=0;
			for(j=1;j<=dl;j++)
			{
				temp=d[j]*i+jw;
				d[j]=temp%10;
				jw=temp/10;
			}
			if(jw!=0)
			{
				while(jw>=10)
				{
					d[j++]=jw%10;
					jw/=10;
				}
				d[j]=jw;
				dl=j;
			}
		}
		temp=0;
		for(i=1;i<=j;i++)
			if(p==d[i])
				temp++;
		printf("%d\n",temp);
	}
	return 0;
}

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