博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nowcoder N约数个数
阅读量:7050 次
发布时间:2019-06-28

本文共 725 字,大约阅读时间需要 2 分钟。

n的约数个数

题目:t次询问,每次给你一个数n,求在[1,n]内约数个数最多的数的约数个数

数据:对于100%的数据,t <= 500 , 1 <= n <= 1000000000000000000

思路:对前20个质数搜索,质数指数依次递减。

代码:

1 #include "bits/stdc++.h" 2  3 #define ll  long long 4 using namespace std; 5 const int mod=1e9+7; 6 const int N=1e6+5; 7 int a[20]={
2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53}; 8 9 ll ans,n;10 void dfs(int p,int up,ll res,ll now){11 if(res>ans) ans=res;12 for(int tot=1;tot<=up&&now<=n/a[p];tot++){13 now*=a[p];14 dfs(p+1,tot,res*(tot+1),now);15 }16 }17 int main() {18 int t;19 cin>>t;20 while(t--){21 cin>>n;22 ans=1;23 dfs(0,63,1,1);24 cout<
<
链接:  

 

转载于:https://www.cnblogs.com/mj-liylho/p/7183293.html

你可能感兴趣的文章
Spring常用注解汇总
查看>>
10大最重要的Web安全风险之六--A6-安全误配置
查看>>
Hibernate【与Spring整合】
查看>>
NOIP2018 游记
查看>>
Redis 和 Memcached 的区别
查看>>
关于tcp状态及一些延展
查看>>
JS入门
查看>>
.vimrc
查看>>
内容显示在HTML页面底端的一些处理方式
查看>>
字符编码总结
查看>>
【个人笔记】《知了堂》express模块
查看>>
java中不能用小数点(.)来做分隔符
查看>>
GIT仓库如何恢复到前一次提交
查看>>
详见github
查看>>
Vue 2.0 Application Sample
查看>>
二分图匹配之最大匹配——匈牙利算法
查看>>
不要重复发明轮子-C++STL
查看>>
1.Repeater控件
查看>>
windbg使用
查看>>
js中的in-for循环
查看>>