B. Easy Number Challenge


B. Easy Number Challenge
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Let's denote d(n) as the number of divisors of a positive integer n. You are given three integers ab 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 ab 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
20
input
Copy
5 6 7
output
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.

传送门

题意:

      给三个数,求出三个数所有组合的乘积拥有的因子个数之和。

思路:

    a,b,c都不超过100,暴力解决,算法核心是找出因子个数。那么要如何求出因子个数呢?

      首先要明白:对于一个整数x,所有x的倍数都含有x这个因子(有一种逆素数筛的感觉是吧)。知道这个,这道题就解了一大半了。


#include<bits/stdc++.h>
/*#include<iostream>
#include<stdio.h>
#include<ctype.h>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<climits>
#include<vector>
#include<map>
#include<queue>*/

#define LL long long
#define inf 0x7f7f7f7f
const int N=1e6;//因为a,b,c最大就100,那范围就跑不出100*100*100 
using namespace std;

long long s[N];//s[i]表示整数i的因子个数 

//核心:生成因数表 
void f()
{
	for(int i=1;i<=N+1;i++)
		for(int j=i;j<=N+1;j+=i)//j始终为i的倍数 
			s[j]++;
}

int main()
{	
	int a,b,c;
	cin>>a>>b>>c;
	
	int ans=0;
	
	for(int i=1;i<=a;i++)
		for(int j=1;j<=b;j++)
			for(int k=1;k<=c;k++)
			{
				ans+=s[i*j*k];//找到因子个数加起来就是答案了 
			}
			
	cout<<ans;
	
} 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值