51nod 1060反素数
经典题。
#include<map>
#include<queue>
#include<stack>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define INF 1000000001
#define ll unsigned long long
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
const int MAXN = ;
int prime[]={,,,,,,,,,,,,,,,,,,,};
ll n;
ll ans,ans_cnt;
void getarcprime(ll cur,ll cnt,int limit,int k)
{
if(cur > n)return;
if(cnt > ans_cnt){
ans_cnt = cnt;
ans = cur;
}
else if(cnt == ans_cnt && cur < ans){
ans = cur;
}
for(int i = ; i <= limit; i++){
if(n / prime[k] < cur){
return;
}
getarcprime(cur*prime[k],cnt*(i+),i,k+);
cur = cur*prime[k];
}
}
int main()
{
int t;
cin >>t;
while(t--){
cin >>n;
ans = ;
ans_cnt = ;
getarcprime(,,,);
cout<<ans<<" "<<ans_cnt<<endl;
}
return ;
}
51nod 1060反素数的更多相关文章
- 51nod 1060 最复杂的数(数论,反素数)
题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1060 题解:可以去学习一下反素数. #include < ...
- 51nod 1060 最复杂的数 反素数
1060 最复杂的数 基准时间限制:1 秒 空间限制:131072 KB 把一个数的约数个数定义为该数的复杂程度,给出一个n,求1-n中复杂程度最高的那个数. 例如:12的约数为:1 2 3 4 6 ...
- 1060 最复杂的数(反素数玄学dfs)
1060 最复杂的数 题目来源: Ural 1748 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题 把一个数的约数个数定义为该数的复杂程度,给出一个n,求1-n中 ...
- 51nod1060(反素数&dfs)
题目链接:https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1060 题意:中文题诶- 思路: 这里用到了反素数的性质: 对 ...
- bzoj1053: [HAOI2007]反素数ant
51nod有一道类似的题...我至今仍然不会写暴搜!!! #include<cstdio> #include<cstring> #include<iostream> ...
- 【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 ...
随机推荐
- CF722D. Generating Sets[贪心 STL]
D. Generating Sets time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- NOIP2002pj产生数[floyd 高精度]
背景 给出一个整数 n(n<10^30) 和 k 个变换规则(k<=15). 规则:一位数可变换成另一个一位数:规则的右部不能为零. 例如:n=234.有规则(k=2):2-> 53 ...
- 第六章、Struts2数据校验
一.三种实现方式 ① 用validate()方法实现数据校验 继承ActionSupport类,该类实现了Validateable接口,该接口中定义了一个validate()方法,在自定义的Actio ...
- AC日记——欧几里得的游戏 洛谷 P1290
题目描述 欧几里德的两个后代Stan和Ollie正在玩一种数字游戏,这个游戏是他们的祖先欧几里德发明的.给定两个正整数M和N,从Stan开始,从其中较大的一个数,减去较小的数的正整数倍,当然,得到的数 ...
- AC日记——加密的病历单 openjudge 1.7 12
12:加密的病历单 总时间限制: 1000ms 内存限制: 65536kB 描述 小英是药学专业大三的学生,暑假期间获得了去医院药房实习的机会. 在药房实习期间,小英扎实的专业基础获得了医生的一致 ...
- Ahead-of-time compilation(AOT)
Ahead-of-time (AOT) compilation is the act of compiling a high-level programming language such as C ...
- [No00002F]3步,教你如何分解需求
对于产品新人来说,如果没有好师傅带,单枪匹马很难形成好的产品思路.有时候和研发沟通,双方都无法理解对方的想法,或者自己在写需求的时候,不是东丢点就是西漏点,老是被开发追着走.今天我就简单说一下个人的需 ...
- vijos1426兴奋剂检查(多维费用的背包问题+状态压缩+hash)
背景 北京奥运会开幕了,这是中国人的骄傲和自豪,中国健儿在运动场上已经创造了一个又一个辉煌,super pig也不例外……………… 描述 虽然兴奋剂是奥运会及其他重要比赛的禁药,是禁止服用的.但是运动 ...
- rpc使用举例
#server.py from SimpleXMLRPCServer import SimpleXMLRPCServer def add(x,y): return x+y server=SimpleX ...
- BZOJ 3524: [Poi2014]Couriers
3524: [Poi2014]Couriers Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 1905 Solved: 691[Submit][St ...