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 ...
随机推荐
- inverse理解
首先术语inverse 被翻译为反转的意思.inverse 制定了关联关系中的方向. 当set的inverse属性默认情况下,hibernate会按照持久化对象的属性变化来同步更新数据库. 得到两条s ...
- XBOX ONE游戏开发之登陆服务器(一)
XBOX ONE游戏开发之登陆服务器(一) XBOX LIVE是微软自已的认证服务器, 当我们开发游戏时,如果是联网游戏,需要自已架设单点登陆(SSO)服务器 这个需要微软提供Relying Part ...
- 渗透中Necat的另类用法
Necat 是一个伟大而实用的用于 TCP 和 UPD 网络连接协议的读写程序.同时 Necat 也被誉为网络中的瑞士军刀,在许多黑客教程中 Necat 也被广泛使用.Necat 最常见用途是设置反向 ...
- uva10344 23 out of 5
Your task is to write a program that can decide whether you can nd an arithmetic expression consisti ...
- 用javascript实现html元素的增删查改[xyytit]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 为什么xcode7请求不成功
1.现在有的工程因为升级xcode7不能进行请求数据,新特性要求App内访问的网络必须使用HTTPS协议.但是现在公司的项目使用的是HTTP协议,使用私有加密方式保证数据安全.现在也不能马上改成HTT ...
- css3和原生js时钟
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 包含文件函数include与require的区别
include或include_once一般用于动态包含,所谓动态包含就是根据不同条件包含不同文件 require或require_once一般用于静态包含,比如包含一个html文件的头部或者尾部 如 ...
- webclient 比浏览器加载页面慢的一个问题
测试中发现webclient 比浏览器加载页面慢的一个问题:原因WebClient 支持 gzip, deflate,但是未设置 解决方案: class WebClientEx : WebClient ...
- IOS-利用AFNetworking监听网络状态
网络环境检测:检测用户当前所处的网络状态 效果图 1.当蜂窝和wifi同时关闭时候 显示为不可达(AFNetworkReachabilityStatusNotReachable)状态 2.打开蜂窝移 ...