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

高精度幂ac(c++)

Posted by 0810311106 at 2009-10-15 11:48:28 on Problem 3331 and last updated at 2009-10-15 11:48:50
#include"iostream"
using namespace std;
int main()
{
	int n;
	cin>>n;
	while(n--)
	{
         int f,s,num=0;
		 int a[1000]={0},temp=0;
		 int i,j,len=1;
		 a[0]=1;
		 cin>>f>>s;
		 for(i=1;i<=f;i++)
		 {
			 for(j=0;j<len;j++)
			 {
				 a[j]=a[j]*i+temp;
			     temp=a[j]/10;
				 a[j]%=10;
			 }
                while(temp!=0)
				{
					a[j]+=temp%10;
					temp/=10;
					j++;
				}
				len=j;
		 }
		 /*for(i=0;i<len;i++)
			 cout<<a[len-1-i];
		 cout<<endl;*/
		 for(i=0;i<len;i++)
			 if(s==a[i])
				 num++;
			 cout<<num<<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