求a[1] × a[2] × …… × a[10]的约数个数。
以下是我的代码:
#include <iostream>
#include <map>
#include <cstdio>
using namespace std;
typedef unsigned long long int64;
int64 a[17];
map<int64,int64> r;
void Input ()
{
for ( int i = 1; i <= 10; i++ )
cin >> a[i];
}
void Fac ( int64 x )
{
while ( ( x & 1 ) == 0 )
{
x >>= 1;
r[2]++;
}
for ( int i = 3; i * i <= x; i+= 2 )
while ( x % i == 0 )
{
x/=i;
r[i]++;
}
if ( x != 1 )
r[x]++;
}
void Solve ()
{
r.clear();
for ( int i = 1; i <= 10; i++ )
Fac ( a[i] );
int ans = 1;
for ( map<int64,int64>::iterator i = r.begin(); i != r.end(); i++ )
{
//cout << i->first << " " << i->second << endl;
ans *= i->second + 1;
}
cout << ans % 10 << endl;
}
int main ()
{
Input ();
Solve ();
return 0;
}
posted on 2011-09-12 09:53
lee1r 阅读(428)
评论(0) 编辑 收藏 引用 所属分类:
题目分类:数学/数论