B. Easy Number Challenge(有技巧的枚举)

Let's denote d(n) as the number of divisors of a positive integer n. You are given three integers a, b and c. Your task is to calculate the following sum:

Find the sum modulo 1073741824 (230).

Input

The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 100).

Output

Print a single integer — the required sum modulo 1073741824 (230).

Examples

Input

Copy

2 2 2

Output

Copy

20

Input

Copy

5 6 7

Output

Copy

1520

Note

For the first example.

  • d(1·1·1) = d(1) = 1;
  • d(1·1·2) = d(2) = 2;
  • d(1·2·1) = d(2) = 2;
  • d(1·2·2) = d(4) = 3;
  • d(2·1·1) = d(2) = 2;
  • d(2·1·2) = d(4) = 3;
  • d(2·2·1) = d(4) = 3;
  • d(2·2·2) = d(8) = 4.

So the result is 1 + 2 + 2 + 3 + 2 + 3 + 3 + 4 = 20.

比赛时超时了好几次,最后开了个数组保存已经计算过的,就AC了。

AC Code:

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define LL long long
#define maxn (LL)1e7
#define INF 0x3f3f3f3f
#define PI  acos(-1.0)
const double eps = 0.0000001;
using namespace std;
inline int sgn(double x) {
    return (x > eps) - (x < -eps);
}
#define re register
static char buf[100000],*pa=buf,*pd=buf;
#define gc pa==pd&&(pd=(pa=buf)+fread(buf,1,100000,stdin),pa==pd)?EOF:*pa++
inline LL read()
{
    re LL x(0),f(1);re char c(gc);
    while(c>'9'||c<'0')f=c=='-'?-1:1,c=gc;
    while(c>='0'&&c<='9')x=x*10+c-48,c=gc;
    return f*x;
}
LL MOD = 1073741824;
LL F[maxn];
int  main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   // memset(ans,-1,sizeof(ans));
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif // ONLINE_JUDGE
    LL a,b,c;
    cin>>a>>b>>c;
    LL num = 0;
    for(LL i =1;i<=a;++i)
    {
        for(LL j = 1;j<=b;++j)
        {
            for(LL k = 1;k<=c;++k)
            {
                LL d = i*j*k;
                if(F[d]) {//若计算过就直接相加
                    num += F[d];continue;
                }
                LL sum = 0;
                for(LL h = 1;h<=sqrt(d);++h)
                if(d%h==0){
                sum = (sum+1);
                if(d/h!=h) sum = (sum+1);
                }
                F[d] = sum;
                num += F[d];
            }
        }
    }
    cout<

 没有想到还可以这样写,orz,巧妙呐

ACCode:

#include 
using namespace std;
int d[1000010];
int main()
{
	
	int a,b,c,i,j,k,s=0;
	
	for(i = 1;i<=1000000;i++)
    for(j = i;j<=1000000;j+=i)//i为因子,j为i的倍数
	 d[j]++;//预处理
	 
	cin>>a>>b>>c;
	
	for(i=1;i<=a;i++)
	for(j=1;j<=b;j++)
	for(k=1;k<=c;k++)
	{
		s+=d[i*j*k];
	}
	cout<

 

你可能感兴趣的:(暴力,思维,枚举)