Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- /// Typedef
- typedef long long ll;
- #define sc1(a) scanf("%lld",&a)
- #define sc2(a,b) scanf("%lld %lld",&a,&b)
- #define pf1(a) printf("%lld\n", a)
- #define pf2(a,b) printf("%lld %lld\n",a,b)
- #define mx 10000007
- #define mod 1000000007
- #define PI acos(-1.0)
- #define size1 10005
- int drx[8] = {-2,-2,-1,-1,1,1,2,2};
- int dcy[8] = {-1,1,-2,2,-2,2,-1,1};
- int dirx[4] = { -1, 0, 1, 0 };
- int diry[4] = { 0, -1, 0, 1 };
- ll save[6000];
- void check()
- {
- save[0] = 1;
- ll pos2 = 0, pos3 = 0, pos5 = 0, pos7 = 0;
- for(ll i = 1; i < 5842; i++){
- save[i] = min(min(2 * save[pos2], 3 * save[pos3]), min(5 * save[pos5], 7 * save[pos7]));
- if(save[i] == 2 * save[pos2]) pos2++;
- if(save[i] == 3 * save[pos3]) pos3++;
- if(save[i] == 5 * save[pos5]) pos5++;
- if(save[i] == 7 * save[pos7]) pos7++;
- }
- }
- int main()
- {
- ll tc, num, t = 1;
- // freopen("/opt/Coding/clion code/input.txt", "r", stdin);
- //freopen("/opt/Coding/clion code/output.txt", "w", stdout);
- check();
- while (cin >> num && num){
- ll last = num % 10;
- if(last == 1 && num % 100 != 11)
- cout << "The " << num << "st humble number is " << save[num - 1] << "." << endl;
- else if(last == 2 && num % 100 != 12)
- cout << "The " << num << "nd humble number is " << save[num - 1] << "." << endl;
- else if(last == 3 && num % 100 != 13)
- cout << "The " << num << "rd humble number is " << save[num - 1] << "." << endl;
- else
- cout << "The " << num << "th humble number is " << save[num - 1] << "." << endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment