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 youngtree at 2007-08-11 14:18:46 on Problem 3331
总是wrong answer,耽误一点时间,谢谢。

#include <iostream>
using namespace std;

int count_num(int i,int j)
{
	int res=0;

	int prod=1;
	for(int k=1;k<=i;++k)
	{
		prod *= k;
	}

	while(prod!=0)
	{
		if((prod-(prod/10)*10)==j)
		{
			res++;
		}
		prod /= 10;
	}
	return res;
}

int main(int argc,char* argv[])
{
	int num=0;
	cin>>num;
	for(int k=0;k<num;++k)
	{
		int i=0,j=0;
		cin>>i>>j;
		
		cout<<count_num(i,j)<<endl;
	}
	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