Discription

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 ≤ 2000).

Output

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

Example

Input
2 2 2
Output
20
Input
4 4 4
Output
328
Input
10 10 10
Output
11536

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,然后设 to(i) 为有多少对有序对(x,y) 满足 1<=x<=a 且 1<=y<=b 且 x*y==i。

然后式子就是 Σ(i=1 to a*b) to(i) Σ(j=1 to c) d(i*j)

这个用约数个数函数的基本式子就可以化简,最后可以 用不到 O(a*b*log(a*b)) 的时间计算出答案。

所以a,b就取三个数中最小的两个就行了。

#include<bits/stdc++.h>
#define ll long long
#define maxn 4000000
using namespace std;
const int ha=1<<30;
int a,b,c,miu[maxn+5];
int zs[maxn/5],t=0,D,low[maxn+5];
int d[maxn+5],to[maxn+5],ans=0;
bool v[maxn+5]; inline void init(){
for(int i=1;i<=a;i++)
for(int j=1;j<=b;j++) to[i*j]++;
miu[1]=d[1]=low[1]=1; for(int i=2;i<=maxn;i++){
if(!v[i]) zs[++t]=i,miu[i]=-1,low[i]=i,d[i]=2;
for(int j=1,u;j<=t&&(u=zs[j]*i)<=maxn;j++){
v[u]=1; if(!(i%zs[j])){
low[u]=low[i]*zs[j];
if(low[i]==i) d[u]=d[i]+1;
else d[u]=d[low[u]]*d[i/low[i]];
break;
}
low[u]=zs[j],d[u]=d[i]<<1,miu[u]=-miu[i];
}
} for(int i=1;i<=maxn;i++) d[i]+=d[i-1];
} inline int add(int x,int y){
x+=y;
return x>=ha?x-ha:x;
} inline void calc(){
for(int i=1,sum;i<=c;i++) if(miu[i]){
sum=0;
for(int j=i;j<=D;j+=i) sum=add(sum,to[j]*(ll)(d[j/i]-d[j/i-1])%ha);
sum=sum*(ll)d[c/i]%ha;
if(miu[i]==1) ans=add(ans,sum);
else ans=add(ans,ha-sum);
}
printf("%d\n",ans);
} int main(){
scanf("%d%d%d",&a,&b,&c);
if(a>b) swap(a,b);
if(a>c) swap(a,c);
if(b>c) swap(b,c);
D=a*b; init();
calc(); return 0;
}

  

Codeforces 235 E Number Challenge的更多相关文章

  1. [codeforces 235]A. LCM Challenge

    [codeforces 235]A. LCM Challenge 试题描述 Some days ago, I learned the concept of LCM (least common mult ...

  2. 【codeforces 235E】 Number Challenge

    http://codeforces.com/problemset/problem/235/E (题目链接) 题意 给出${a,b,c}$,求${\sum_{i=1}^a\sum_{j=1}^b\sum ...

  3. Codeforces 235E. Number Challenge DP

    dp(a,b,c,p) = sigma ( dp(a/p^i,b/p^j,c/p^k) * ( 1+i+j+k) ) 表示用小于等于p的素数去分解的结果有多少个 E. Number Challenge ...

  4. Easy Number Challenge(暴力,求因子个数)

    Easy Number Challenge Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I ...

  5. Codeforces 55D Beautiful Number

    Codeforces 55D Beautiful Number a positive integer number is beautiful if and only if it is divisibl ...

  6. 『NYIST』第八届河南省ACM竞赛训练赛[正式赛一]CF-236B. Easy Number Challenge

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

  7. Java实现 蓝桥杯 算法训练 Number Challenge(暴力)

    试题 算法训练 Number Challenge 资源限制 时间限制:3.0s 内存限制:512.0MB 问题描述 定义d(n)为n的约数个数.现在,你有三个数a,b,c.你的任务是计算下面式子mod ...

  8. Codeforces 235E Number Challenge

    http://codeforces.com/contest/235/problem/E 远距离orz......rng_58 证明可以见这里(可能要FQ才能看到) 还是copy一下证明吧: 记 $$f ...

  9. 洛谷 P3327 [SDOI2015]约数个数和 || Number Challenge Codeforces - 235E

    https://www.luogu.org/problemnew/show/P3327 不会做. 去搜题解...为什么题解都用了一个奇怪的公式?太奇怪了啊... 公式是这样的: $d(xy)=\sum ...

随机推荐

  1. python的标准模块

    本文用于记录python中的标准模块,随时更新. decimal模块(解决小数循环问题): >>> import decimal >>> a = decimal.D ...

  2. The 2018 ACM-ICPC China JiangSu Provincial Programming Contest I. T-shirt

    JSZKC is going to spend his vacation! His vacation has N days. Each day, he can choose a T-shirt to ...

  3. loj2005 「SDOI2017」相关分析

    鬼畜线段树--Orz Capella #include <iostream> #include <cstdio> using namespace std; int n, m, ...

  4. [POJ 1001] Exponentiation C++解题报告 JAVA解题报告

        Exponentiation Time Limit: 500MS   Memory Limit: 10000K Total Submissions: 126980   Accepted: 30 ...

  5. mongo以及mysql常用语句

    db.user.find({']}}).pretty(); db.user.find({primaryPhone:).forEach(function(user){print('my phonenum ...

  6. 为Anaconda添加新的源

    为Anaconda添加新的源 在cmd中输入以下内容即可, 清华的源,速度非常快 conda config --add channels https://mirrors.tuna.tsinghua.e ...

  7. HLG2179 组合(dfs水水更健康)

    组合 Time Limit: 1000 MS Memory Limit: 32768 K Total Submit: 57(38 users) Total Accepted: 43(36 users) ...

  8. 九度oj 题目1443:Tr A

    题目描述: A为一个方阵,则Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973. 输入: 数据的第一行是一个T,表示有T组数据. 每组数据的第一行有n(2 <= n & ...

  9. 前面板插口耳机无声音?无Realtek控制器?

    今天碰到一个很恶心的问题,电脑又没有声音了, 因为新装的系统,怀疑没有驱动,就装了驱动,还是没有有声音, 网上搜了半天都是让在控制面板找Realtek控制器,可以我的控制面板没有. 最后找到一篇百度经 ...

  10. java反射的基本使用

    反射机制是java中非常重要的功能,熟练使用反射功能对实际的开发有很大的帮助. 一,通过反射获取对象实例 使用的对象User package whroid.java.reflect; public c ...