细心点想,就明白了,题目是求和为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. HDU Distinct Values

    /* 一开始想到的是 对于每个区间操作 先按左端点排序(包含的区间 留这打的区间) 我们维护pos表示 a数组找到了哪 对于当前这个区间 只需要找 pos--r这个区间 用set维护能用的数 没放到a ...

  2. html5 初探

    html5是越来越火了.小小菜鸟也来学习学习. 相比于之前的几个版本,HTML5提供了更加丰富的多媒体标签使得音乐,视频的播放不用再借助于flah了.不过暂时各浏览器间样式还是有差别. 除此之外,表单 ...

  3. springboot @WebFilter过滤器的使用

    过滤器的用法就不多说了 新建Filter的继承类:MemberFilter(放置包需要注意) @WebFilter(urlPatterns = "/*") @Order(1) pu ...

  4. shp系列(二)——利用C++进行shp文件的读(打开)

    1.各数据类型及其字节数 BYTE 1;       char 1;    short 2;      int 4;    double 8; 2.位序big和little及其转换 对于位序是big的 ...

  5. Centos上运行.net core2.0

    一.在centos7上安装.net core sdk 微软文档:https://www.microsoft.com/net/learn/get-started/linux/centos 二.直接在Ce ...

  6. (转)19 个 JavaScript 有用的简写技术

    1.三元操作符 当想写if...else语句时,使用三元操作符来代替. const x = 20; let answer; if (x > 10) { answer = 'is greater' ...

  7. (转载) popupWindow 指定位置上的显示

    popupWindow 指定位置上的显示 标签: androidpopupWindowpopupWindow具体位置放置 2014-07-09 16:23 1114人阅读 评论(0) 收藏 举报  分 ...

  8. android黑科技系列——静态分析技术来破解Apk

    一.前言 从这篇文章开始我们开始我们的破解之路,之前的几篇文章中我们是如何讲解怎么加固我们的Apk,防止被别人破解,那么现在我们要开始破解我们的Apk,针对于之前的加密方式采用相对应的破解技术,And ...

  9. android系统源码下载

    ubuntu 安装git curl python 确保主目录下有一个 bin/ 目录,并且该目录包含在路径中: mkdir ~/bin PATH=~/bin:$PATH   下载 Repo 工具,并确 ...

  10. 【Oracle】数据库热备

    1. 创建脚本 注:脚本第三行中的DB_NAME,需要改为自己的数据库名(show parameter name;): oracle用户下新建目录:/home/oracle/DB_NAME/hot_b ...