1748

反素数

素数的个数随大小的递增而递减 可以相同

注意各种超啊

 #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<cmath>
using namespace std;
#define INF 1e19
#define LL unsigned long long
#define N 32000
int p[N],f[N],g,po[N];
LL maxz,tt,pp[N][],n;
void init()
{
int i,j; for(i = ; i < N ; i++)
if(!f[i])
{
for(j = i+i ; j < N ; j+=i)
f[j] = ;
}
for(i = ; i < N ; i++)
if(!f[i])
p[++g] = i;
for(i = ; i <= g ; i++)
{
pp[p[i]][] = p[i];
for(j = ; ; j++)
{
double ss = (double)pp[p[i]][j-]*p[i];
if(ss>INF) break;
pp[p[i]][j]=ss;
//cout<<ss<<endl; }
po[i] = j-;
}
}
void dfs(LL s,int k,int o,LL sum)
{
int i;
LL ts =s;
if(o>) return ;
if(maxz<sum||(maxz==sum&&tt>s))
{
maxz = sum;
tt = s;
}
for(i = ; i <= min(k,po[o]) ; i++)
{
if(n/s<pp[p[o]][i]) break;
s*=pp[p[o]][i];
dfs(s,i,o+,sum*(LL)(i+));
s = ts;
}
}
int main()
{
int t,i;
init();
cin>>t;
while(t--)
{
cin>>n;
maxz=,tt=;
for(i = ; i < po[] ; i++)
{
LL s = pp[][i];
if(s>n)
{
if(i>maxz)
{
maxz = i;
tt = pp[][i-];
}
break;
}
dfs(s,i,,i+);
}
cout<<tt<<" "<<maxz<<endl;
}
return ;
}

URAL1748. The Most Complex Number的更多相关文章

  1. LeetCode 537. 复数乘法(Complex Number Multiplication)

    537. 复数乘法 537. Complex Number Multiplication 题目描述 Given two strings representing two complex numbers ...

  2. LC 537. Complex Number Multiplication

    Given two strings representing two complex numbers. You need to return a string representing their m ...

  3. ural 1748 The Most Complex Number 和 丑数

    题目:http://acm.timus.ru/problem.aspx?space=1&num=1748 题意:求n范围内约数个数最多的那个数. Roughly speaking, for a ...

  4. [LeetCode] Complex Number Multiplication 复数相乘

    Given two strings representing two complex numbers. You need to return a string representing their m ...

  5. [Swift]LeetCode537. 复数乘法 | Complex Number Multiplication

    Given two strings representing two complex numbers. You need to return a string representing their m ...

  6. LeetCode Complex Number Multiplication

    原题链接在这里:https://leetcode.com/problems/complex-number-multiplication/description/ 题目: Given two strin ...

  7. 【LeetCode】537. Complex Number Multiplication 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 日期 题目地址:https://leetcode.com/pr ...

  8. 537. Complex Number Multiplication

    题目大意: 给出a, b两个用字符串表示的虚数,求a*b 题目思路: 偷了个懒,Python3的正则表达式匹配了一下,当然acm里肯定是不行的 class Solution: def complexN ...

  9. URAL 1748. The Most Complex Number(反素数)

    题目链接 题意 :给你一个n,让你找出小于等于n的数中因子个数最多的那个数,并且输出因子个数,如果有多个答案,输出数最小的那个 思路 : 官方题解 : (1)此题最容易想到的是穷举,但是肯定超时. ( ...

随机推荐

  1. [百度空间] [原]android下的各种坑

    一堆so文件安装不正确: apk里面都是全的, 但是安装完后/data/data/$pkg/lib下面就没有 google了好长时间没有结果.最后发现是因为没库有加lib前缀(当时想了一下觉得不加更好 ...

  2. HackPorts – Mac OS X 渗透测试框架与工具

    HackPorts是一个OS X 下的一个渗透框架. HackPorts是一个“超级工程”,充分利用现有的代码移植工作,安全专业人员现在可以使用数以百计的渗透工具在Mac系统中,而不需要虚拟机. 工具 ...

  3. python 小试牛刀之信息管理

    这个是之前写的半成品,但是一直没有好好的写完,今晚我把它补充完整,并且贴出了遇到的问题 这个程序并没有处理中文,主要是python 2.7对于中文的支持太蛋疼了,虽然可以设置utf8编码,但是如果列表 ...

  4. Apache CXF实现Web Service(3)——Tomcat容器和不借助Spring的普通Servlet实现JAX-RS(RESTful) web service

    起步 参照这一系列的另外一篇文章: Apache CXF实现Web Service(2)——不借助重量级Web容器和Spring实现一个纯的JAX-RS(RESTful) web service 首先 ...

  5. Maven在项目中的应用

    http://192.168.0.253:8081/nexus/#view-repositories;thirdparty~uploadPanel 使用局域网搭建的环境,输入用户名和密码登录,上传ja ...

  6. Sqli-labs less 25

    Less-25 本关主要为or and过滤,如何绕过or和and过滤.一般性提供以下几种思路: 大小写变形 Or,OR,oR 编码,hex,urlencode 添加注释/*or*/ 利用符号 and= ...

  7. uva 10817

    Problem D: Headmaster's Headache Time limit: 2 seconds The headmaster of Spring Field School is cons ...

  8. POJ 1027 The Same Game(模拟)

    题目链接 题意 : 一个10×15的格子,有三种颜色的球,颜色相同且在同一片内的球叫做cluster(具体解释就是,两个球颜色相同且一个球可以通过上下左右到达另一个球,则这两个球属于同一个cluste ...

  9. Tomcat6启用Gzip压缩功能

    配置Tomcat根目录下/conf/server.xml文件: <Connector port="8080" protocol="HTTP/1.1" co ...

  10. intelli IDEA node开发代码提示问题

    好几天没写代码了,今天新建一个项目,在引入rs这个文件系统模块时却没有关于这个模块的代码提示,着实令人恶心啊.还好最终解决了. 在没有代码提示的时候点击如下图标: 出现如下的界面,其中有个Edit u ...