Guest User

Untitled

a guest
Feb 16th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. /// Typedef
  6. typedef long long ll;
  7.  
  8. #define sc1(a) scanf("%lld",&a)
  9. #define sc2(a,b) scanf("%lld %lld",&a,&b)
  10.  
  11. #define pf1(a) printf("%lld\n", a)
  12. #define pf2(a,b) printf("%lld %lld\n",a,b)
  13.  
  14. #define mx 10000007
  15. #define mod 1000000007
  16. #define PI acos(-1.0)
  17.  
  18. #define size1 10005
  19.  
  20. int drx[8] = {-2,-2,-1,-1,1,1,2,2};
  21. int dcy[8] = {-1,1,-2,2,-2,2,-1,1};
  22.  
  23. int dirx[4] = { -1, 0, 1, 0 };
  24. int diry[4] = { 0, -1, 0, 1 };
  25.  
  26. ll save[6000];
  27.  
  28. void check()
  29. {
  30. save[0] = 1;
  31.  
  32. ll pos2 = 0, pos3 = 0, pos5 = 0, pos7 = 0;
  33.  
  34. for(ll i = 1; i < 5842; i++){
  35. save[i] = min(min(2 * save[pos2], 3 * save[pos3]), min(5 * save[pos5], 7 * save[pos7]));
  36.  
  37. if(save[i] == 2 * save[pos2]) pos2++;
  38. if(save[i] == 3 * save[pos3]) pos3++;
  39. if(save[i] == 5 * save[pos5]) pos5++;
  40. if(save[i] == 7 * save[pos7]) pos7++;
  41. }
  42.  
  43. }
  44.  
  45. int main()
  46. {
  47. ll tc, num, t = 1;
  48.  
  49. // freopen("/opt/Coding/clion code/input.txt", "r", stdin);
  50. //freopen("/opt/Coding/clion code/output.txt", "w", stdout);
  51.  
  52. check();
  53.  
  54. while (cin >> num && num){
  55.  
  56. ll last = num % 10;
  57.  
  58. if(last == 1 && num % 100 != 11)
  59. cout << "The " << num << "st humble number is " << save[num - 1] << "." << endl;
  60. else if(last == 2 && num % 100 != 12)
  61. cout << "The " << num << "nd humble number is " << save[num - 1] << "." << endl;
  62. else if(last == 3 && num % 100 != 13)
  63. cout << "The " << num << "rd humble number is " << save[num - 1] << "." << endl;
  64. else
  65. cout << "The " << num << "th humble number is " << save[num - 1] << "." << endl;
  66.  
  67. }
  68.  
  69. return 0;
  70. }
Add Comment
Please, Sign In to add comment