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. [noip2005提高]过河 dp

    由于L的范围到了109,用普通dp做肯定是不成了: 可以观察到M的数量很小,dp在转移的过程中有大量的无用转移: 可以想到压缩范围,问题是如何压缩,观察若S=9,T=10时,能到达的点,9,10,18 ...

  2. 【NOI模拟赛(湖南)】DeepDarkFantasy

    DeepDarkFantasy 从东京出发,不久便到一处驿站,写道:日暮里.  ——鲁迅<藤野先生> 定义一个置换的平方为对1~n的序列做两次该置换得到的序列.已知一个置换的平方,并且这个 ...

  3. word插件开发 运行时,插件不启动.

      word插件开发 运行时,插件不启动. 查看插件信息时. 在禁用的应用程序加载项中.   启动禁用的插件: 点击转到.  选择你要启动的插件就可以了.

  4. 6 高级IO函数

    6.1 pipe函数 pipe函数创建一个管道,用于实现进程间通信 #include<unistd.h> ]); 参数包含两个文件描述符fd[0]和fd[1],往fd[1]写入的数据可以从 ...

  5. quickeys 过期解决办法

    自己在系统中找了大半天,终于发现了一个叫.com.quickeys.quickeysX3.plist的文件,存在于硬盘的 ~/Library/Preferences/ 目录下,直觉感觉文件的大体内容应 ...

  6. 将HTML转成XHTML并清除一些无用的标签和属性

    介绍 这是一个能帮你从HTML生成有效XHTML的经典库.它还提供对标签以及属性过滤的支持.你可以指定允许哪些标签和属性可在出现在输出中,而其他的标签过滤掉.你也可以使用这个库清理Microsoft ...

  7. 纯js页面跳转整理

    js方式的页面跳转1.window.location.href方式    <script language="javascript" type="text/java ...

  8. tomcat 多开设置 需要需改的3个端口

    启动多tomcat需要需改的3个端口 我所用Tomcat服务器都为zip版,非安装版.以两个为例: 安装第二个Tomcat完成后,到安装目录下的conf子目录中打开server.xml文件,查找以下三 ...

  9. Redis与Memcached的incr/decr差异对比

    目前广泛使用的分布式缓存Redis和Memcached均支持对整数型Value值的增减,对应到具体命令中就是incr和decr命令. incr/decr是原子性操作(memcached 1.2.4及以 ...

  10. POJ 3185

    The Water Bowls Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4088   Accepted: 1609 D ...