• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# noname41 (NUMBER)

leminhkt Apr 9th, 2020 136 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>
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.
57.     int n;
58.     map<int, bool> d, a;
59.     int prc(int m){
60.         if(d[m]) return a[m];
61.         else{
62.             d[m] = 1;
63.             int x = m, t = 0;
64.             while (x)
65.                 t += sqr(x % 10),
66.                 x /= 10;
67.             a[m] = prc(t);
68.         }
69.     }
70.
71. /* ----------------- ~~~~~~~ ----------------- */
72.
73. int main(){
74.     // freopen("NUMBER.inp", "r", stdin);
75.     // freopen("NUMBER.out", "w", stdout);
76.     // ios_base::sync_with_stdio(0); cin.tie(0);
77.
78.         /* ----------------- main func ----------------- */
79.
80.     d[1] = 1, a[1] = 1;
81.     while(cin >> n){
82.         while(prc(++n) == 0);
83.         Write(n); putchar('\n');
84.     }
85.
86. /* ----------------- ~~~~~~~~~ ----------------- */
87. }
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.
Top