題解:求出n以內的最大的反素數。
#include#include using namespace std; typedef unsigned long long LL; LL p[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53}; LL ans,sum; LL N; void dfs(LL i,LL x,LL n) { if(n>sum||(n==sum&&ans>x)) sum=n,ans=x; for(int k=1;k<=63;k++) { if(x*p[i]>N) break; dfs(i+1,x*=p[i],n*(k+1)); } } int main() { while(cin>>N) { ans=1e18; sum=1; dfs(0,1,1); cout<