高精度的题目
一个高精的的数乘以int
然后统计里面k出现的次数就好了
1#include<stdio.h>
2#include<string.h>
3int a[400][1000];
4int l[400];
5int n,m;
6int main()
7{
8 int t,KASE,ans,i,j;
9 scanf("%d",&KASE);
10 memset(l,-1,sizeof(l));
11 memset(a,0,sizeof(a));
12 a[0][0]=1;l[0]=1;
13 for(i=1;i<=365;i++)
14 {
15 t=l[i-1];
16 for(j=0;j<t;j++)a[i][j]=a[i-1][j]*i;
17 //for(j=t-1;j>=0;j--)printf("%d",a[i][j]);printf("\n");
18 for(j=0;j<t-1;j++)
19 {
20 a[i][j+1]+=a[i][j]/10;
21 a[i][j]%=10;
22 }
23 l[i]=l[i-1];
24/**//*
25 for(j=0;j<t-1;j++)
26 {
27 a[i][j+1]+=a[i][j]/10;
28 a[i][j]%=10;
29 }
30*/
31 while(a[i][l[i]-1]>10)
32 {
33 // printf("asdasdasdasd\n");
34 a[i][l[i]]+=a[i][l[i]-1]/10;
35 a[i][l[i]-1]%=10;
36 l[i]++;
37 }
38 }
39 //printf("%dasdasda",a[4][1]);
40
41 for(i=0;i<KASE;i++)
42 {
43 scanf("%d%d",&n,&m);
44 ans=0;
45 for(j=0;j<l[n];j++)if(a[n][j]==m)ans++;
46 printf("%d\n",ans);
47 }
48 return 0;
49}
50
51