Maruf_Hasan

HCN

May 7th, 2020
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1.  
  2. //In the Name of Allah Most Gracious, Most Merciful//
  3. /*If you want something you've never had, you have to do something you never did.*/
  4.  
  5. #include<bits/stdc++.h>
  6. using namespace std;
  7.  
  8.  
  9. #define pb push_back
  10. #define ll long long
  11. #define pii pair<int,int>
  12. #define pll pair<ll,ll>
  13. #define M 100007
  14. #define INF 1e9
  15. #define INFL 1e18
  16. #define PI acos(-1)
  17. #define mp make_pair
  18. #define fast_in_out ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  19. //const int fx[]= {+1,-1,+0,+0};
  20. //const int fy[]= {+0,+0,+1,-1};
  21. //const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1}; // Kings Move
  22. //const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
  23. //const int fx[]={-2, -2, -1, -1, 1, 1, 2, 2}; // Knights Move
  24. //const int fy[]={-1, 1, -2, 2, -2, 2, -1, 1}; // Knights Move
  25.  
  26. int prime[]={2,3,5,7,11,13,17,19,23};
  27.  
  28. int n;
  29. int resnum;
  30. int resdiv;
  31.  
  32. void HCNfunction(int pos,int limit,long long num,int div)
  33. {
  34. if(div>resdiv)
  35. {
  36. resnum=num;
  37. resdiv=div;
  38. }
  39. else if(div==resdiv && num<resnum)
  40. {
  41. resnum=num;
  42. }
  43. if(pos==9)
  44. return;
  45. long long p=prime[pos];
  46. for(int i=1;i<=limit;i++)
  47. {
  48. if(num*p>n)
  49. break;
  50. HCNfunction(pos+1,i,num*p,div*(i+1));
  51. p=p*prime[pos];
  52. }
  53. }
  54.  
  55.  
  56.  
  57. int main ()
  58. {
  59. n = 1000000000;
  60. resnum = 0;
  61. resdiv = 0;
  62. HCNfunction( 0, 30, 1, 1 );
  63. printf ( "%d %d\n", resnum, resdiv );
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment