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的素数去分解的结果有多少个
3 seconds
512 megabytes
standard input
standard output
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).
The first line contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 2000).
Print a single integer — the required sum modulo 1073741824 (230).
2 2 2
20
4 4 4
328
10 10 10
11536
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的更多相关文章
- Codeforces 235E Number Challenge
http://codeforces.com/contest/235/problem/E 远距离orz......rng_58 证明可以见这里(可能要FQ才能看到) 还是copy一下证明吧: 记 $$f ...
- CodeForces 235E Number Challenge (莫比乌斯反演)
题意:求,其中d(x) 表示 x 的约数个数. 析:其实是一个公式题,要知道一个结论 知道这个结论就好办了. 然后就可以解决这个问题了,优化就是记忆化gcd. 代码如下: #pragma commen ...
- codeforces Hill Number 数位dp
http://www.codeforces.com/gym/100827/attachments Hill Number Time Limits: 5000 MS Memory Limits: ...
- Codeforces 251C Number Transformation DP, 记忆化搜索,LCM,广搜
题意及思路:https://blog.csdn.net/bossup/article/details/37076965 代码: #include <bits/stdc++.h> #defi ...
- CF#235E. Number Challenge
传送门 可以理解为上一道题的扩展板.. 然后我们就可以YY出这样一个式子 ${\sum_{i=1}^a\sum_{j=1}^b\sum_{k=1}^cd(ijk)=\sum_{i=1}^a\sum_{ ...
- Easy Number Challenge(暴力,求因子个数)
Easy Number Challenge Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I ...
- Codeforces Avito Code Challenge 2018 D. Bookshelves
Codeforces Avito Code Challenge 2018 D. Bookshelves 题目连接: http://codeforces.com/contest/981/problem/ ...
- 多校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 用作标记,当现在枚举的数小 ...
- Codeforces 235E
Codeforces 235E 原题 题目描述:设\(d(n)\)表示\(n\)的因子个数, 给定\(a, b, c\), 求: \[\sum_{i=1}^{a} \sum_{j=1}^{b} \su ...
随机推荐
- spring-boot-mybatis-多数据源
sql 语句 DROP TABLE IF EXISTS `users`; CREATE TABLE `users` ( `id` bigint(20) NOT NULL AUTO_INCREMENT ...
- 2017/05/23 java 基础 随笔
1.多态的好处: a.提高了代码的维护性(继承保证) b.提高了代码的扩展性(由多态保证) package com.huawei; public class Demo2 { public static ...
- Java练习之使用StringBuilder
package string.demo; /* * 将数组变为字符串输出 */ public class StringBuilderTest { /** * @param args */ public ...
- mysql区间范围查询问题
一,日期区间查询,表里有一个时间字段 最常见的就是某时间段查询,比如xxxx时间---xxxx时间有多少条数据.例如数据库里的字段是 income_period, 该字段类型可以是字符串(varcha ...
- 打包部署到tomcat
部署到tomcat的方法 注意:在eclipse 或 idea 上需要引入外部tomcat 1.将程序打成war包启动tomcat 2.将target 文件下内容压缩城zip,发布到tomcat RO ...
- OpenLayers 3 之 地图图层数据来源(ol.source)详解
原文地址 source 是 Layer 的重要组成部分,表示图层的来源,也就是服务地址.除了在构造函数中制定外,可以使用 layer.setSource(source) 稍后指定.一.包含的类型 ol ...
- css初始化minireset.css
一个很小的现代CSS重置,涵盖了基本内容: 重置字体大小:这样使用语义标记不会影响样式 重置块边距:所以只有在需要时才应用间距 重置表格:这样表格数据只占用它所需的空间 保留了行内间距:因此,按钮和输 ...
- Kaggle案例分析3--Bag of Words Meets Bags of Popcorn
项目描述:这是一个关于情感分析的教程.谷歌的Word2Vec(文本深度表示模型)是一个由深度学习驱动的方法, 旨在获取words内部的含义.Word2Vec试图理解单词之间的含义与语义关系.它类似于r ...
- springmvc上下文与springcontext上下文的关系
内容摘自:springmvc与spring上下文的关系 原理区别 一直不清楚springmvc-servlet.xml配置与spring.xml两个配置文件出现的上下文关系.今天找到一上面的文章,倒是 ...
- java 添加自己的工具包
一. 在添加工具包前环境变量要定位到当前目录, export CLASSPATH=.:/home/share/ 添加工具类 我的目录\\192.168.1.101\share\share\net\fe ...