#include #include #include #include using namespace std; #define MAX 316228 long long N; bool arr[MAX+1]; long long insuu[MAX]; long long insuun=0; long long pn[MAX]; long long pc=0; long long ansmin; map>>> memo; void search2(long long a,long long b,long long c,int sn,int pl){ if(memo.find(a)!=memo.end()&&memo[a].find(b)!=memo[a].end()&&memo[a][b].find(c)!=memo[a][b].end()&&memo[a][b][c].find(sn)!=memo[a][b][c].end()){ return; } else{ memo[a][b][c][sn]=a+b+c; memo[a][c][b][sn]=a+b+c; memo[b][a][c][sn]=a+b+c; memo[b][c][a][sn]=a+b+c; memo[c][b][a][sn]=a+b+c; memo[c][a][b][sn]=a+b+c; } if(a+b+c>=ansmin) return; if(sn==-1||sn==insuun){ ansmin=min(ansmin,a+b+c); return; } search2(a*insuu[sn],b,c,sn+pl,pl); search2(a,b*insuu[sn],c,sn+pl,pl); search2(a,b,c*insuu[sn],sn+pl,pl); } int main(){ cin>>N; long long ansmax=N-1; for(long long i=0;i<=MAX;i++){ arr[i]=true; } arr[0]=false; arr[1]=false; for(long long i=2;i<=MAX;i++){ if(arr[i]){ pn[pc]=i; pc++; for(long long j=i*2;j<=MAX;j+=i){ arr[j]=false; } } } for(long long i=0;i