EntropyIncreaser

HDU 6754

Jul 21st, 2020
1,363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.89 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cstring>
  3. #include <cstdlib>
  4. #include <cmath>
  5. #include <ctime>
  6. #include <cctype>
  7.  
  8. #include <algorithm>
  9. #include <random>
  10. #include <bitset>
  11. #include <queue>
  12. #include <functional>
  13. #include <set>
  14. #include <map>
  15. #include <vector>
  16. #include <chrono>
  17. #include <iostream>
  18. #include <limits>
  19. #include <numeric>
  20.  
  21. #define LOG(FMT...) fprintf(stderr, FMT)
  22.  
  23. using namespace std;
  24.  
  25. typedef long long ll;
  26. typedef unsigned long long ull;
  27.  
  28. // mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  29.  
  30. template <class T>
  31. istream& operator>>(istream& is, vector<T>& v) {
  32.   for (T& x : v)
  33.     is >> x;
  34.   return is;
  35. }
  36.  
  37. template <class T>
  38. ostream& operator<<(ostream& os, const vector<T>& v) {
  39.   if (!v.empty()) {
  40.     os << v.front();
  41.     for (int i = 1; i < v.size(); ++i)
  42.       os << ' ' << v[i];
  43.   }
  44.   return os;
  45. }
  46.  
  47. const int P = 998244353;
  48.  
  49. int norm(int x) { return x >= P ? (x - P) : x; }
  50.  
  51. void add(int& x, int y) { if ((x += y) >= P) x -= P; }
  52.  
  53. void sub(int& x, int y) { if ((x -= y) < 0) x += P; }
  54.  
  55. void exGcd(int a, int b, int& x, int& y) {
  56.   if (!b) {
  57.     x = 1;
  58.     y = 0;
  59.     return;
  60.   }
  61.   exGcd(b, a % b, y, x);
  62.   y -= a / b * x;
  63. }
  64.  
  65. int inv(int a) {
  66.   int x, y;
  67.   exGcd(a, P, x, y);
  68.   return norm(x + P);
  69. }
  70.  
  71. int mpow(int x, int k) {
  72.   int ret = 1;
  73.   while (k) {
  74.     if (k & 1)
  75.       ret = ret * (ll)x % P;
  76.     x = x * (ll)x % P;
  77.     k >>= 1;
  78.   }
  79.   return ret;
  80. }
  81.  
  82. int main() {
  83. #ifdef ELEGIA
  84.   freopen("test.in", "r", stdin);
  85.   int nol_cl = clock();
  86. #endif
  87.   ios::sync_with_stdio(false);
  88.   cin.tie(nullptr);
  89.  
  90.   int T;
  91.   cin >> T;
  92.   while (T--) {
  93.     int n;
  94.     cin >> n;
  95.     int ans;
  96.     if (n <= 3) ans = mpow(26, n);
  97.     else
  98.       ans = 26 * 25 * 24;
  99.     cout << ans << '\n';
  100.   }
  101.  
  102. #ifdef ELEGIA
  103.   LOG("Time: %dms\n", int ((clock()
  104.           -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
  105. #endif
  106.   return 0;
  107. }
Advertisement
Add Comment
Please, Sign In to add comment