Saleh127

UVA 443

Sep 5th, 2020
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; while(t--)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);
  9. cout.tie(0);
  10.  
  11. ll a[10000]= {0};
  12. ll i,j,k,l,c,d,e,n,x=0;
  13. for(i=0; i<=30; i++)
  14. {
  15. for(j=0; j<=19; j++)
  16. {
  17. c=pow(2,i)*pow(3,j);
  18. if(c<2000000001)
  19. {
  20. for(k=0; k<=13; k++)
  21. {
  22. c=pow(2,i)*pow(3,j)*pow(5,k);
  23. if(c<2000000001)
  24. {
  25. for(l=0; l<=11; l++)
  26. {
  27. c=pow(2,i)*pow(3,j)*pow(5,k)*pow(7,l);
  28. if(c<2000000005 && a[x]==0)
  29. {
  30. a[x]=c;
  31. x++;
  32. }
  33. else break;
  34. }
  35. }
  36. }
  37. }
  38. }
  39. }
  40. sort(a,a+x);
  41. while(cin>>n && n)
  42. {
  43. printf("The %d", n);
  44. if(n%10 == 1 && n%100 != 11) printf("st");
  45. else if(n%10 == 2 && n%100 != 12) printf("nd");
  46. else if(n%10 == 3 && n%100 != 13) printf("rd");
  47. else printf("th");
  48. printf(" humble number is %d.\n", a[n-1]);
  49. }
  50.  
  51. return 0;
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment