先用筛法求出1到10000的所有素数,建立素数表。依次对ai分解质因数,统计所有质因数出现的次数ti,最后的约数个数为 (t1+1)*(t2+1)*(t3+1)*...*(tn+1)
1 #include <iostream>
2 using namespace std;
3 const int maxn=10000;
4 int su[1300],sn;
5 bool he[maxn+1];
6 int num[1300];
7
8 void work(int x){
9 int d=x;
10 x+=d;
11 while (x<=maxn){
12 he[x]=true;
13 x+=d;
14 }
15 }
16
17 int main(){
18 for (int i=2;i<=maxn;++i) if (!he[i]) work(i);
19 sn=0;
20 for (int i=2;i<=maxn;++i) if (!he[i]) su[++sn]=i;
21 for (int i=1;i<=10;++i){
22 int x;
23 scanf("%d",&x);
24 int p=1;
25 while (x>1){
26 while (x%su[p]==0&&x>1){
27 x/=su[p];
28 ++num[p];
29 }
30 ++p;
31 }
32 }
33 int ans=1;
34 for (int i=1;i<=sn;++i){
35 ans*=num[i]+1;
36 ans%=10;
37 }
38 cout<<ans;
39 }
40
posted on 2008-11-06 18:36
Joseph 阅读(103)
评论(0) 编辑 收藏 引用