HDU 4228
很明显可以转化为反素数的题目。由于有n种不同的方式,所以,数的约数可以为2*n或者2*n-1
#include <iostream>
#include <cstdio>
#include <cstring>
#define LL __int64 using namespace std; LL p[16]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53};
LL n,k; void dfs(LL dep,LL tmp,LL num, LL &ans){
if(num>k) return;
if(num==k){
if(tmp<ans)
ans=tmp;
return ;
}
for(LL i=1;i<=60;i++){
if(tmp*p[dep]>ans) break;
tmp*=p[dep];
dfs(dep+1,tmp,num*(i+1),ans);
}
} int main(){
while(scanf("%I64d",&n),n){
k=2*n;
LL ansi=(1LL<<60);
// cout<<ansi<<endl;
dfs(0,1,1,ansi);
// cout<<ansi<<endl;
k=2*n-1;
LL ansj=(1LL<<60);
dfs(0,1,1,ansj);
// cout<<ansj<<endl;
printf("%I64d\n",ansi<ansj?ansi:ansj);
}
return 0;
}
HDU 4228的更多相关文章
- ZOJ 2562 HDU 4228 反素数
反素数: 对于不论什么正整数x,起约数的个数记做g(x).比如g(1)=1,g(6)=4. 假设某个正整数x满足:对于随意i(0<i<x),都有g(i)<g(x),则称x为反素数. ...
- HDU 4228 Flooring Tiles 反素数
推出了结论,万万没想到最后用搜索.. 还想dp来着.. #include <cstdio> #include <cstring> #include <iostream&g ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
随机推荐
- C 中 main 函数的參数
看到不同的人写出的 C 或者 C++ 程序时,可能会出现不一样的 main 函数的定义,以下的几种定义方式都是对的: int main(void) int main(int argc) i ...
- 简单list转化为tree结构
1 @Override public List<Module> getTree() { List<Module> list = moduleMapper.queryList() ...
- Linux学习之设置联网,关闭防火墙,关闭selinux
桥接模式,给一台物理机,有自己独立的IP. boot分区,引导分区,系统启动,内核文件. swap分区,内存扩展分区.1.5或2倍.内存不够的时候,会写入其中.正常给8G或者16G就够了.不需要非要1 ...
- php中全局变量global和超全局变量$GLOBALS
php中全局变量global和超全局变量$GLOBALS 1.global Global的作用是定义全局变量,但是这个全局变量不是应用于整个网站,而是应用于当前页面,包括include或require ...
- hdoj--1151--Air Raid(最大独立集)
Air Raid Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total S ...
- x+=y与x=x+y相同吗?
为了将赋值操作简便化,Java提供了很多扩展赋值运算符,例如+=.-=./=.*=等等,那么问题来了,x += 1与x = x +1两者相同吗? public class EqualsTest { @ ...
- 前端分页功能实现(PC)
<!DOCTYPE html><html> <head> <meta charset="utf-8"> <title>加 ...
- eclipse中文汉字看不清或过小的问题解决方法!!
把字体修改为 中欧字体就可以看清汉字
- ueditor和flexpaper的学习。。。。
博客园的博主编辑文本的时候在博客园编辑器上编辑的,最近见到并学习了一点百度一款ueditor的编辑器可供程序猿们二次开发.... 见链接http://fex.baidu.com/ueditor/#st ...
- MapReduce架构与生命周期
MapReduce架构与生命周期 概述:MapReduce是hadoop的核心组件之一,可以通过MapReduce很容易在hadoop平台上进行分布式的计算编程.本文组织结果如下:首先对MapRedu ...