标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5194 Accepted Submission(s): 3043
题解:反素数模版没搞出来,暴力倒是立马ac。。。
代码:
#include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<vector> #include<algorithm> using namespace std; typedef unsigned long long uLL; const uLL INF=(uLL)~0; const double PI=acos(-1.0); #define SI(x) scanf("%d",&x) #define SL(x) scanf("%lld",&x) #define PI(x) printf("%d",x) #define PL(x) printf("%lld",x) #define T_T while(T--) #define P_ printf(" ") int prim[16]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53}; uLL ans,a,b; int nm,flot; /*void dfs(int pos,uLL v,int num){ if(num==nm&&ans>v)ans=v; if(v>=a&&v<=b&&num>nm)ans=v,nm=num,flot=1; for(int i=1;i<=63;i++){ if(v*prim[pos]>b)break; dfs(pos+1,v*=prim[pos],num*(i+1)); } }*/ int js(int temp){ int num=1; for(int i=2;i<temp;i++){ int x=0; if(temp%i==0){ while(temp%i==0)x++,temp/=i; num*=(x+1); } } if(temp>1)num*=2; return num; } int main(){ int T; SI(T); T_T{ scanf("%llu%llu",&a,&b); int nm=0; for(int i=a;i<=b;i++){ int temp=js(i); if(temp>nm)nm=temp,ans=i; } printf("%llu\n",ans); } return 0; }
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/5017654.html