Ledger Nano X - The secure hardware wallet
SHARE
TWEET

noname41 (NUMBER)

a guest Apr 9th, 2020 133 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. #include<conio.h>
  3. #include<time.h>
  4.  
  5.  
  6. #define ll long long
  7. #define ld long double
  8. #define FOR(i, a, b) for(ll i=(a); i<=(b); i++)
  9. #define FORn(i, n) for(ll i=1; i<=(n); i++)
  10. #define FORx(i, a, b, n) for(ll i=(a); i<=(b); i+=(x))
  11. #define FORa(i, b) for(; i<=(b); i++)
  12. #define FORax(i, b, x) for(; i<=(b); i+=(x))
  13. #define FORR(i, a, b) for(ll i=(a); i>=(b); i--)
  14. #define FORRn(i, n) for(ll i=(n); i>=1; i--)
  15. #define FORRx(i, a, b, n) for(ll i=(a); i>=(b); i-=(x))
  16. #define FORRa(i, b) for(; i>=(b); i--)
  17. #define FORRax(i, b, x) for(; i>=(b); i-=(x))
  18. #define pb(x) push_back(x)
  19. #define all(x) (x).begin(), (x).end()
  20. #define sz(x) (x).size()
  21. #define sqr(x) (ll)(x)*(x)
  22. #define PI (2*acos(0))
  23. using namespace std;
  24.  
  25.  
  26. template <typename T>
  27. inline void Read(T& x)
  28. {
  29.     bool Neg = false;
  30.     char c;
  31.     for (c = getchar(); c < '0' || c > '9'; c = getchar())
  32.         if (c == '-') Neg = !Neg;
  33.     x = c - '0';
  34.     for (c = getchar(); c >= '0' && c <= '9'; c = getchar())
  35.         x = x * 10 + c - '0';
  36.     if (Neg) x = -x;
  37. }
  38. template <typename T>
  39. inline void Write(T x)
  40. {
  41.     if (x < 0)
  42.     {
  43.         putchar('-'); x = -x;
  44.     }
  45.     T p = 1;
  46.     for (T temp = x / 10; temp > 0; temp /= 10) p *= 10;
  47.     for (; p > 0; x %= p, p /= 10) putchar(x / p + '0');
  48. }
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.         /* ----------------- ~~~~~~~ ----------------- */
  56.     int n;
  57.     map<int, bool> d, a;
  58.     int prc(int m){
  59.         if(d[m]) return a[m];
  60.         else{
  61.             d[m] = 1;
  62.             int x = m, t = 0;
  63.             while (x)
  64.                 t += sqr(x % 10),
  65.                 x /= 10;
  66.             a[m] = prc(t);
  67.         }
  68.     }
  69.  
  70.  
  71.  
  72.  
  73.  
  74. /* ----------------- ~~~~~~~ ----------------- */
  75.  
  76. int main(){
  77.     freopen("NUMBER.inp", "r", stdin);
  78.     freopen("NUMBER.out", "w", stdout);
  79.     ios_base::sync_with_stdio(0); cin.tie(0);
  80.  
  81.         /* ----------------- main func ----------------- */
  82.     d[1] = 1, a[1] = 1;
  83.     while(cin >> n){
  84.         while(prc(++n) == 0);
  85.         Write(n); putchar('\n');
  86.     }
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93. /* ----------------- ~~~~~~~~~ ----------------- */
  94. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top