dp(a,b,c,p) = sigma ( dp(a/p^i,b/p^j,c/p^k) * ( 1+i+j+k) )

表示用小于等于p的素数去分解的结果有多少个

E. Number Challenge
time limit per test

3 seconds

memory limit per test

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

Output

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

Sample test(s)
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.


import java.util.*;

public class CF235E {

	class Triple {

		Triple(){}

		Triple(int _x,int _y,int _z) {
this.x=_x; this.y=_y; this.z=_z;
this.sort();
} public int x,y,z; void sort() {
if(this.z<this.y) {
int t = this.z;
this.z=this.y;
this.y=t;
}
if(this.z<this.x) {
int t=this.x;
this.x=this.z;
this.z=t;
}
if(this.y<this.x) {
int t=this.x;
this.x=this.y;
this.y=t;
}
} @Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + getOuterType().hashCode();
result = prime * result + x;
result = prime * result + y;
result = prime * result + z;
return result;
} @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Triple other = (Triple) obj;
if (!getOuterType().equals(other.getOuterType()))
return false;
if (x != other.x)
return false;
if (y != other.y)
return false;
if (z != other.z)
return false;
return true;
} private CF235E getOuterType() {
return CF235E.this;
}
} int a,b,c;
final int mod = 1073741824 ; int[] primes = new int[350];
int pn=0; boolean[] vis = new boolean[2200]; Map[] map = new Map[333];
void init() {
for(int i=2;i<=2100;i++) {
if(vis[i]==false) {
primes[pn++]=i;
for(int j=2*i;j<=2100;j+=i)
vis[j]=true;
}
}
for(int i=0,j=pn-1;i<=j;i++,j--) {
int t=primes[i];
primes[i]=primes[j];
primes[j]=t;
}
for(int i=0;i<333;i++)
map[i]=new HashMap<Triple,Integer>();
} long gao(int deep,Triple tri) { if(deep==pn) return 1; if(map[deep].get(tri)!=null) return (long) map[deep].get(tri);
long ret=0; int p=primes[deep]; for(int x=tri.x,i=0;x!=0;x/=p,i++) {
for(int y=tri.y,j=0;y!=0;y/=p,j++) {
for(int z=tri.z,k=0;z!=0;z/=p,k++) {
ret+=gao(deep+1,new Triple(x,y,z))*(i+j+k+1)%mod;
if(ret>=mod) {
ret-=mod;
}
}
}
}
map[deep].put(tri, ret);
return ret;
} CF235E(){
init();
Scanner in = new Scanner(System.in);
a=in.nextInt(); b=in.nextInt(); c=in.nextInt();
System.out.println(gao(0,new Triple((int)a,(int)b,(int)c)));
} public static void main(String[] args) {
new CF235E();
}
}

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

  1. Codeforces 235E Number Challenge

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

  2. CodeForces 235E Number Challenge (莫比乌斯反演)

    题意:求,其中d(x) 表示 x 的约数个数. 析:其实是一个公式题,要知道一个结论 知道这个结论就好办了. 然后就可以解决这个问题了,优化就是记忆化gcd. 代码如下: #pragma commen ...

  3. codeforces Hill Number 数位dp

    http://www.codeforces.com/gym/100827/attachments Hill Number Time Limits:  5000 MS   Memory Limits: ...

  4. Codeforces 251C Number Transformation DP, 记忆化搜索,LCM,广搜

    题意及思路:https://blog.csdn.net/bossup/article/details/37076965 代码: #include <bits/stdc++.h> #defi ...

  5. CF#235E. Number Challenge

    传送门 可以理解为上一道题的扩展板.. 然后我们就可以YY出这样一个式子 ${\sum_{i=1}^a\sum_{j=1}^b\sum_{k=1}^cd(ijk)=\sum_{i=1}^a\sum_{ ...

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

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

  7. Codeforces Avito Code Challenge 2018 D. Bookshelves

    Codeforces Avito Code Challenge 2018 D. Bookshelves 题目连接: http://codeforces.com/contest/981/problem/ ...

  8. 多校5 HDU5787 K-wolf Number 数位DP

    // 多校5 HDU5787 K-wolf Number 数位DP // dp[pos][a][b][c][d][f] 当前在pos,前四个数分别是a b c d // f 用作标记,当现在枚举的数小 ...

  9. Codeforces 235E

    Codeforces 235E 原题 题目描述:设\(d(n)\)表示\(n\)的因子个数, 给定\(a, b, c\), 求: \[\sum_{i=1}^{a} \sum_{j=1}^{b} \su ...

随机推荐

  1. 第11月第20天 sqlite3_open xcode mysql connector

    1. sqlite3_open 死锁 * thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP frame ...

  2. 判断gps是否在国内

    参考文章:[WP7]判断GPS坐标是否在中国 根据国家行政边界判定(光线投射算法) 按需求调整了原文中的部分边界值,测试几组边界附近内外坐标,结果较为准确. /** * 判断GPS坐标是否在多边形中 ...

  3. Django Rest Framework-APIView源码分析

    class APIView(View): # The following policies may be set at either globally, or per-view. renderer_c ...

  4. 解决urbuntu桌面本客户端输入ll command not found

    用桌面版的urbuntu系统,打开客户端输入ll,报错如下 于是度娘,解决方案:可以作如下修改:打开 ~/.bashrc 找到 #alias ll=’ls -l’,去掉前面的#就可以了.(关闭原来的终 ...

  5. Windows下RabbitMQ安装及配置

    下载rabbitmq_server以及Erlang OTP平台 安装好了启动服务就行了 也可用命令 net start RabbitMQ  或  net stop RabbitMQ 配置用户添加环境变 ...

  6. RGBA颜色与兼容性的半透明背景色

    所谓RGBA颜色,顾名思意就是R+G+B+A的颜色,再具体点就是RED+GREEN+BLUE+ALPHA的颜色,小写一下就是red+green+blue+alpha的颜色,翻译一下就是红+绿+蓝+Al ...

  7. centos7配置svn钩子hooks脚本自动同步代码到项目目录

    由于项目需要,svn提交后的代码希望再测试服务器上测试,每次提交后还要手动去svn update一次 十分麻烦,配置好svn钩子以后就省去了这些麻烦. 进入svn版本库目录找到hooks目录找到文件p ...

  8. 【AtCoder】ARC085

    C - HSI 题解 \(E = 1900 * (N - M) + 100 * M + \frac{1}{2^{M}} E\) \(E = 2^{M}(1900 * (N - M) + 100 * M ...

  9. Mysql 查看用户

    一.查看用户和允许用户登录的地址权限. use mysql select host,user from user; 二.查看用户和所有用户权限 select * from user \G

  10. hadoop2.6.4的HA集群搭建超详细步骤

    hadoop2.0已经发布了稳定版本了,增加了很多特性,比如HDFS HA.YARN等.最新的hadoop-2.6.4又增加了YARN HA 注意:apache提供的hadoop-2.6.4的安装包是 ...