CF27E 反素数

xiaoxiao2021-02-28  22

https://vjudge.net/problem/CodeForces-27E

类似于BZOJ上反素数的那道题

都是搜索的这类做法

AC代码:

#include<bits/stdc++.h> using namespace std; typedef long long ll; ll p[20]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53}; const ll inf =1e18; ll ans; ll n; void dfs(ll deep,ll tmp,ll num){ cout<<n<<endl; if(num>n) return; if(num==n&&ans>tmp) ans=tmp; for(ll i=1;i<=63;++i){ if(ans/p[deep]<tmp) break; dfs(deep+1,tmp*=p[deep],num*(i+1)); } } int main(){ cin>>n; ans=inf; dfs(0,1,1); cout<<ans<<endl; }
转载请注明原文地址: https://www.6miu.com/read-2632687.html

最新回复(0)