细心点想,就明白了,题目是求和为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. IOS UITextView光标位置在中间的问题

    在viewDidLoad中 if ([selfrespondsToSelector:@selector(setAutomaticallyAdjustsScrollViewInsets:)]) { se ...

  2. libcanbus官方主页

    libcanbus canbus(CAN BUS V2.0 B)扩展格式库项目简析 注: 本文如果你已经有linux开发环境 请确保你使用本库时是tag版本号. 该库遵循的协议是SAE J1939-2 ...

  3. spring框架spring之HibernateTemplate

    转自:https://blog.csdn.net/acmman/article/details/44652207

  4. First step in troubleshooting complex issues: Define and scope your issue properly

    最近在查调试相关资料的时候,无意看到Tess的一篇关于如何快速分析复合场景问题的博文,感觉很实用,Mark备忘. My 9 questions for a pretty thorough proble ...

  5. jquery 获取及设置input各种类型的值

    获取选中的值 获取一组radio被选中项的值 var item = $(“input[@name=items]:checked”).val(); 获取select被选中项的文本 var item = ...

  6. myslide探索

    最近查一些国内学术牛人的报告时,注意到myslide是个很好的平台,比如山大一个老师的报告,完全可以在上面看到 https://myslide.cn/slides/10774 又比如交大一个大牛老师关 ...

  7. C# 2.0新加特性

    泛型(Generics) 泛型是CLR 2.0中引入的最重要的新特性,使得可以在类.方法中对使用的类型进行参数化. 例如,这里定义了一个泛型类: class MyCollection<T> ...

  8. 添加图标:before 和 :after css中用法

    #sTitle:after{ position: absolute; top: 2px; font-family: "FontAwesome"; content: "\f ...

  9. sass揭秘之@mixin,%,@function(转载)

    因为文章内含有很多sass代码,如需自己动手查看编译结果,推荐使用sassmeister这款在线编译工具,方便你阅读学习. 在阅读本文章之前,请先确认你已经阅读了上篇文章sass揭秘之变量,不然会给你 ...

  10. spring重点一:处理对象创建时间 个数以及方式

    /** * 1) 对象创建: 单例/多例(个数) * scope="singleton", 默认值, 即 默认是单例 [service/dao/工具类] *  scope=&quo ...