| ||||||||||
| 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 | |||||||||
高精度幂ac(c++)#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator