细心点想,就明白了,题目是求和为N的各数的最小公倍数的种数。其实就是求N以内的各素数的不同的组合(包含他们的次方),当然,是不能超过N的。用Dp能解决。和背包差不多。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define N 1010
#define LL __int64
using namespace std; LL dp[N]; int prim[N],np;
bool isprime[N]; void init(){
np=;
memset(isprime,true,sizeof(isprime));
for(int i=;i<N;i++){
if(isprime[i]){
prim[++np]=i;
for(int j=i*i;j<N;j+=i)
isprime[j]=false;
}
}
} int main(){
init();
int n,tmp;
while(scanf("%d",&n)!=EOF){
for(int i=;i<=n;i++)
dp[i]=1LL;
bool flag=false;
for(int k=;k<=np;k++){
if(prim[k]>n) break;
for(int i=n;i>=;i--){
tmp=prim[k];
while(i-tmp>=){
dp[i]+=dp[i-tmp];
tmp*=prim[k];
}
}
}
printf("%I64d\n",dp[n]);
}
return ;
}

HDU 4345的更多相关文章

  1. HDU 4345 Permutation dp

    Permutation Problem Description There is an arrangement of N numbers and a permutation relation that ...

  2. hdu 4345 Permutation 记忆化搜索

    思路:实际上求的是和小于等于n的质数的种类数!!! 代码如下: #include<iostream> #include<stdio.h> #include<algorit ...

  3. 【HDU - 4345 】Permutation(DP)

    BUPT2017 wintertraining(15) #8F 题意 1到n的排列,经过几次置换(也是一个排列)回到原来的排列,就是循环了. 现在给n(<=1000),求循环周期的所有可能数. ...

  4. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  6. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  7. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  9. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

随机推荐

  1. Oracle学习(十二):存储过程/存储函数

    1.知识点 --第一个存储过程 /* 打印Hello World create [or replace] PROCEDURE 过程名(參数列表) AS PLSQL子程序体: 调用存储过程: 1. ex ...

  2. 《转》Ceilometer Alarm API 參数具体解释 及 举例说明

    Ceilometer Alarm是H版新加入的功能,监控报警是云平台必不可少的部分,Ceilometer已经实现了比較完好的监控体系.报警怎么能缺少呢?用过AWS CloudWatch Alarm的人 ...

  3. 产生冠军--hdoj

    产生冠军 Time Limit : 1000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submissi ...

  4. Linux Shell Scripting Cookbook 读书笔记 7

    ping, du, ps, kill, 收集系统信息 判断网络中哪些主机是活动主机 #!/bin/bash for ip in 10.215.70.{1..255}; do ( ping $ip -c ...

  5. Linux Shell Scripting Cookbook 读书笔记 3

    patch, tree, head ,tail 1. 创建不可修改文件 chattr +i file chattr -i file 移除不可修改属性 2. 能够启动闪存或硬盘的混合ISO isohyb ...

  6. Python基本数据类型之字符串str

    字符串 定义:它是一个有序的字符的集合,用于存储和表示基本的文本信息,‘’或“”或‘’‘ ’‘’中间包含的内容称之为字符串 字符串的结构类型为'...' "..." "' ...

  7. javascript的基础知识及面向对象和原型属性

    自己总结一下javascript的基础知识,希望对大家有用,也希望大家来拍砖,毕竟是个人的理解啊 1.1 类型检查:typeof(验证数据类型是:string) var num = 123; cons ...

  8. class A<T> where T:new()相关知识点

    来源:http://www.cnblogs.com/FredWang/p/4284251.html class A<T> where T:new()  ===>>>   ...

  9. Nginx配置Q&A

    隐藏响应头 How can remove Nginx from http response header? - Stack Overflow more_set_headers 'Server: my- ...

  10. RAP开发入门-开发笔记-bug记录

    NamespaceException: The alias '/rwt-resources' is already in use 该bug发生的第一种情况是: This means that more ...