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<<
链接: