4427

dp[i][j][k] i为K位的最小公倍数 j为k位的和 k以滚动数组的形式

这题最棒的是 有一个强有力的剪枝 组成公倍数m的肯定都是M的质因子 这样1000里面最多就30多个 复杂度可过了

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<queue>
using namespace std;
#define mod 1000000007
int dp[][][];
int q[][],f[],lc[][];
int p[];
int gcd(int a,int b)
{
return b==?a:gcd(b,a%b);
}
int main()
{
int n,m,k,i,j,g;
for(i = ; i <= ; i++)
for(j = ; j <= ; j++)
lc[i][j] = i*j/gcd(i,j);
while(scanf("%d%d%d",&n,&m,&k)!=EOF)
{
int o;
int to = ;
for(i =; i <= m ; i++)
if(m%i==)
{
to++;
p[to] = i;
}
memset(dp,,sizeof(dp));
for(i = ; i <= min(n,m) ; i++)
{
dp[i][i][] = ;
}
for(i = ; i <= k; i++)
{
for(o = ; o <= to ; o++)
for(g = ; g <= n ; g++)
dp[p[o]][g][i%] = ;
for(j = ; j <= to ; j++)
{
for(g = i-; g <= n ; g++)
{
if(dp[p[j]][g][(i-)%]==)
continue;
for(o = ; o <= to ; o++)
{
int x = lc[p[j]][p[o]];
if(g+p[o]>n)
break;
if(x>m)
continue;
dp[x][g+p[o]][i%] = (dp[x][g+p[o]][i%]+dp[p[j]][g][(i-)%])%mod;
}
}
}
}
printf("%d\n",dp[m][n][k%]);
}
return ;
}

hdu4427Math Magic的更多相关文章

  1. Codeforces CF#628 Education 8 D. Magic Numbers

    D. Magic Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  2. [8.3] Magic Index

    A magic index in an array A[0...n-1] is defined to be an index such that A[i] = i. Given a sorted ar ...

  3. Python魔术方法-Magic Method

    介绍 在Python中,所有以"__"双下划线包起来的方法,都统称为"Magic Method",例如类的初始化方法 __init__ ,Python中所有的魔 ...

  4. 【Codeforces717F】Heroes of Making Magic III 线段树 + 找规律

    F. Heroes of Making Magic III time limit per test:3 seconds memory limit per test:256 megabytes inpu ...

  5. 2016中国大学生程序设计竞赛 - 网络选拔赛 C. Magic boy Bi Luo with his excited tree

    Magic boy Bi Luo with his excited tree Problem Description Bi Luo is a magic boy, he also has a migi ...

  6. 一个快速double转int的方法(利用magic number)

    代码: int i = *reinterpret_cast<int*>(&(d += 6755399441055744.0)); 知识点: 1.reinterpret_cast&l ...

  7. MAGIC XPA最新版本Magic xpa 2.4c Release Notes

    New Features, Feature Enhancements and Behavior ChangesSubforms – Behavior Change for Unsupported Ta ...

  8. Magic xpa 2.5发布 Magic xpa 2.5 Release Notes

    Magic xpa 2.5發佈 Magic xpa 2.5 Release Notes Magic xpa 2.5 Release NotesNew Features, Feature Enhance ...

  9. How Spring Boot Autoconfiguration Magic Works--转

    原文地址:https://dzone.com/articles/how-springboot-autoconfiguration-magic-works In my previous post &qu ...

随机推荐

  1. ASP.NET输出PNG图片时出现GDI+一般性错误的解决方法

    偶原来的用ASP.NET生成验证码图片时用的是JPG格式,今天想把它改成PNG格式的,结果就出现GDI+一般性错误,查了N久资料,才发现解决的办法,对分享此解决办法的网友深表感谢 Response.C ...

  2. javascript实现数据结构:线性表--线性链表(链式存储结构)

    上一节中, 线性表的顺序存储结构的特点是逻辑关系上相邻的两个元素在物理位置上也相邻,因此可以随机存取表中任一元素,它的存储位置可用一个简单,直观的公式来表示.然后,另一方面来看,这个特点也造成这种存储 ...

  3. 【译】C++工程师需要掌握的10个C++11特性

    原文标题:Ten C++11 Features Every C++ Developer Should Use 原文作者:Marius Bancila 原文地址:codeproject 备注:非直译,带 ...

  4. Web前端名词释义及原理

    引言:看题目的时候,不要觉得这是一个很深奥的问题,Web前端这些东西很多就是叫的名字牛逼,其实原理很TM简单,也就那么回事. 一.javascript名词释义 1.啥是事件队列? 就是 弄一个数组,里 ...

  5. POJ 2724

    Purifying Machine Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4014   Accepted: 1127 ...

  6. 【mysql5.6】下载安装

    每次学新技术最烦的就是安软件了..... 下载的mysql5.6 http://dev.mysql.com/downloads/windows/ 一路默认安装.安装后 1.以管理员身份打开C:\WIN ...

  7. iOS-OpenGLES 简单渲染

     UIImage *showImage = [UIImage imageNamed:, , showImage.size.width, showImage.size.height);     ) fo ...

  8. (5)VS2010无法打开gl/glaux.h头文件的解决方法

    方法:下载缺少的文件. 参考自:http://blog.csdn.net/delphiwcdj/article/details/6326586 下载源1:CSDN下载OpenGL 安装包所需文件下载: ...

  9. 深入理解Windows X64调试

    随着64位操作系统的普及,都开始大力进军x64,X64下的调试机制也发生了改变,与x86相比,添加了许多自己的新特性,之前学习了Windows x64的调试机制,这里本着“拿来主义”的原则与大家分享. ...

  10. socket传输过程

    连接过程: 根据连接启动的方式以及本地套接字要连接的目标,套接字之间的连接过程可以分为三个步骤:服务器监听,客户端请求,连接确认. (1)服务器监听:是服务器端套接字并不定位具体的客户端套接字,而是处 ...