HDUSTOJ-1558 Flooring Tiles(反素数)
1558: Flooring Tiles
时间限制: 3 Sec 内存限制: 128 MB
提交: 59 解决: 36
[提交][状态][讨论版]
题目描述
You want to decorate your floor with square tiles. You like rectangles. With six square flooring tiles, you can form exactly two unique rectangles that use all of the tiles: 1 x 6, and 2 x 3 (6 x 1 is considered the same as 1 x 6. Likewise, 3 x 2 is the same as 2 x 3). You can also form exactly two unique rectangles with four square tiles, using all of the tiles: 1 x 4, and 2 x 2.
Given an integer N, what is the smallest number of square tiles needed to be able to make exactly N unique rectangles, and no more, using all of the tiles? If N = 2, the answer is 4.
输入
There will be several test cases in the input. Each test case will consist of a single line containing a single integer N, which represents the number of desired rectangles. The input will end with a line with a single `0'.
输出
For each test case, output a single integer on its own line, representing the smallest number of square flooring tiles needed to be able to form exactly N rectangles, and no more, using all of the tiles. The answer is guaranteed to be at most 1018. Output no extra spaces, and do not separate answers with blank lines.
样例输入
2
16
19
0
样例输出
4
840
786432
#include<iostream>
#include<cstring>
#include<cstdio> using namespace std;
typedef long long LL;
LL p[];
LL prime[]= {,,,,,,,,,,,,,,,};
void getartprime(LL cur,int cnt,int limit,int k)
{
//cur:当前枚举到的数;
//cnt:该数的因数个数;
//limit:因数个数的上限;2^t1*3^t2*5^t3……t1>=t2>=t3……
//第k大的素数
if(cur>(1LL<<) || cnt>) return ;
if(p[cnt]!= && p[cnt]>cur)//当前的因数个数已经记录过且当时记录的数比当前枚举到的数要大,则替换此因数个数下的枚举到的数
p[cnt]=cur;
if(p[cnt]==)//此因数个数的数还没有出现过,则记录
p[cnt]=cur;
LL temp=cur;
for(int i=; i<=limit; i++) //枚举数
{
temp=temp*prime[k];
if(temp>(1LL<<)) return;
getartprime(temp,cnt*(i+),i,k+);
}
} void Init(){
getartprime(, , , );
for(int i = ; i <= ; i++){
if(p[*i] != && p[*i-] != ) p[i] = min(p[*i], p[*i-]);
else if(p[*i] != ) p[i] = p[*i];
else p[i] = p[*i - ];
} }
int main(){
int n;
Init();
while(scanf("%d", &n) == && n){
printf("%lld\n", p[n]);
}
}
HDUSTOJ-1558 Flooring Tiles(反素数)的更多相关文章
- HDU 4228 Flooring Tiles 反素数
推出了结论,万万没想到最后用搜索.. 还想dp来着.. #include <cstdio> #include <cstring> #include <iostream&g ...
- 【POJ2886】Who Gets the Most Candies?-线段树+反素数
Time Limit: 5000MS Memory Limit: 131072K Case Time Limit: 2000MS Description N children are sitting ...
- Prime & 反素数plus
题意: 求因数个数为n的最小正整数k. n<=10^9输出其唯一分解形式 SOL: 模拟题,一眼看过去有点惊讶...这不是我刚看过的反素数吗... 咦数据怎么这么大,恩搞个高精吧... 于是T了 ...
- BZOJ 1053 & 反素数
题意: 反素数,膜一篇GOD's Blog...http://blog.csdn.net/ACdreamers/article/details/25049767 此文一出,无与争锋... CODE: ...
- Who Gets the Most Candies?(线段树 + 反素数 )
Who Gets the Most Candies? Time Limit:5000MS Memory Limit:131072KB 64bit IO Format:%I64d &am ...
- BZOJ 3085: 反质数加强版SAPGAP (反素数搜索)
题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=3085 题意:求n(<=10^100)之内最大的反素数. 思路: 优化2: i ...
- ZOJ-2562 More Divisors 反素数
题意:给定一个数N,求小于等于N的所有数当中,约数最多的一个数,如果存在多个这样的数,输出其中最大的一个. 分析:反素数定义:对于任何正整数x,其约数的个数记做g(x).例如g(1)=1,g(6)=4 ...
- 【bzoj1053】反素数
[bzoj1053]反素数 题意 对于任何正整数x,其约数的个数记作g(x).例如g(1)=1.g(6)=4.如果某个正整数x满足:g(x)>g(i) 0<i<x,则称x为反质数.例 ...
- 【BZOJ】【1053】【HAOI2007】反素数ant
搜索 经典搜索题目(其实是蒟蒻只会搜……vfleaking好像有更优秀的做法?) 枚举质数的幂,其实深度没多大……因为$2^32$就超过N了……而且质数不能取的太大,所以不会爆…… /******** ...
随机推荐
- ppt打不开,显示发现文件中的内容有问题。可尝试修复此演示文稿
原因分析 主要是因为文件是网络下载的,office自动锁定了文件(默认不可编辑). 解决办法 在文件上右键-属性-解除锁定(最下面),就不会进行检查了,问题也就解决了. ppt文件---右键---属性 ...
- R语言-三种方法绘制单位圆
与一般开发语言不同,R以数据统计分析和绘图可视化为主要卖点.本文是第一篇博客,解决一个简单的绘图问题,以练手为目的. 以下直接给出三种单位圆的画法: 方法1 f=seq(,*pi,0.001) x=s ...
- frps启动
1.找到frps.ini文件 find / -name 'frps.ini' 2.窗口启动 ./frps -c ./frps.ini 3.关闭窗口,后台运行 setsid ./frps -c ./ ...
- Floyd求解最短路
Floyd算法适用于求解全源最短路.也就是能够求解任意两点间的最短路径并且是适用于含有负权边的图,但是含有负环则不行了!空间复杂度为O(n2).时间复杂度为O(n3).其具体的原理在百度能够找到很多, ...
- 基于Cesium的Web3d实现二三维室内外一体化融合
https://cesiumjs.org/Cesium/Build/Apps/Sandcastle/index.html?src=3D%20Models.html 三维建模 BIM
- MapServer教程3
Compiling on Unix Compiling on Win32 PHP MapScript Installation .NET MapScript Compilation IIS Setup ...
- Last Defence
Given two integers A and B. Sequence S is defined as follow: • S0 = A •S1 = B • Si = |Si−1 − Si−2| f ...
- Oracle Select语句
Oracle Select语句 作者:初生不惑 Oracle基础 评论:0 条 Oracle技术QQ群:175248146 在本教程中,将学习如何使用Oracle SELECT语句从单个表中查询数据. ...
- Python学习笔记(三)- SyntaxError: Non-ASCII character '\xe7' in file
在编辑Python时,当有中文输出或者注释时,出现错误提示:“SyntaxError: Non-ASCII character '\xe7' in file“ 原因:python的默认编码文件是用的A ...
- oracle数据泵导入导出
1.首先建立DUMP_DIR sqlplus / as sysdba select * from dba_directories 如果没有DUMP_DIR就执行下面的语句 CREATE OR REPL ...