fork download
  1. //#pragma GCC optimize("Ofast,unroll-loops")
  2. //#pragma GCC target("avx2,tune=native")
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5.  
  6. #define file "o"
  7. #define ff(i, a, b) for(auto i=(a); i<=(b); ++i)
  8. #define ffr(i, b, a) for(auto i=(b); i>=(a); --i)
  9. #define nl "\n"
  10. #define ss " "
  11. //#define pb push_back
  12. #define pb emplace_back
  13. #define fi first
  14. #define se second
  15. #define sz(s) (int)s.size()
  16. #define all(s) (s).begin(), (s).end()
  17. #define ms(a,x) memset(a, x, sizeof (a))
  18. #define cn continue
  19. #define re return 0; // Thay đổi re thành return 0; cho hàm main
  20.  
  21. typedef long long ll;
  22. typedef unsigned long long ull;
  23. typedef long double ld;
  24. typedef vector<int> vi;
  25. typedef vector<ll> vll;
  26. typedef pair<int, int> pii;
  27. typedef pair<ll, ll> pll;
  28. typedef vector<pii> vpii;
  29. typedef vector<pll> vpll;
  30.  
  31. mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
  32. ll ran(ll l, ll r)
  33. {
  34. return uniform_int_distribution<ll> (l, r)(rng);
  35. }
  36.  
  37. inline void rf()
  38. {
  39. ios_base::sync_with_stdio(false);
  40. cin.tie(nullptr); cout.tie(nullptr);
  41. if(fopen(file".inp","r"))
  42. {
  43. freopen(file".inp","r",stdin);
  44. freopen(file".out","w",stdout);
  45. }
  46. }
  47.  
  48. const int mod=1e9+19972207;
  49. const int maxn=2e5+15;
  50. const ll inf=5e16;
  51.  
  52. template<typename T> inline void add(T &x, const T &y)
  53. {
  54. x+=y;
  55. if(x>=mod) x-=mod;
  56. if(x<0) x+=mod;
  57. }
  58.  
  59. template<typename T> inline bool maxi(T &a, T b)
  60. {
  61. if(a>=b) return 0;
  62. a=b; return 1;
  63. }
  64.  
  65. template<typename T> inline bool mini(T &a, T b)
  66. {
  67. if(a<=b) return 0;
  68. a=b; return 1;
  69. }
  70.  
  71. const int P[] = {1, 1, 2, 6, 4};
  72. const int E[] = {6, 2, 4, 8};
  73.  
  74. ll LNZD_iterative(ll Q) {
  75. ll C = 1;
  76.  
  77. while (Q > 0) {
  78. ll r = Q % 5;
  79. C = (C * P[r]) % 10;
  80.  
  81. ll k = Q / 5;
  82. ll e = k % 4;
  83. C = (C * E[e]) % 10;
  84. Q = k;
  85. }
  86. return C;
  87. }
  88.  
  89.  
  90. signed main()
  91. {
  92. rf();
  93. ll q;
  94. if (!(cin >> q)) re; // Kiểm tra đọc input
  95. ll C = LNZD_iterative(q);
  96. ll result = q * C;
  97. cout << result << nl;
  98.  
  99. re;
  100. }
Success #stdin #stdout 0.01s 5288KB
stdin
6
stdout
12