fork download
  1. //la_flame_ never dies out.
  2. #include <cassert>
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5.  
  6. #define int long long
  7. typedef long double LD;
  8.  
  9. const int MAX = 1e5 + 5;
  10. const int MOD = 1e9 + 7;
  11. const LD EPS = 1e-10;
  12. const LD PI = acos(-1.0);
  13. #define fastio \
  14.   ios_base::sync_with_stdio(false); \
  15.   cin.tie(NULL); \
  16.   cout.tie(NULL);
  17. #define rep(i, a, b, d) for (int i = a; i <= b; i += d)
  18. #define brep(i, a, b, d) for (int i = a; i >= b; i -= d)
  19. #define pb push_back
  20. #define pii pair<int, int>
  21. #define ll long long
  22. #define bara 1000000000000000000
  23.  
  24. int modpow(int x, unsigned int y, int p)
  25. {
  26. int res = 1; // Initialize result
  27.  
  28. x = x % p; // Update x if it is more than or
  29. // equal to p
  30.  
  31. while (y > 0)
  32. {
  33. // If y is odd, multiply x with result
  34. if (y & 1)
  35. res = (res*x) % p;
  36.  
  37. // y must be even now
  38. y = y>>1; // y = y/2
  39. x = (x*x) % p;
  40. }
  41. return res;
  42. }
  43.  
  44. int32_t main()
  45. {
  46. int tc; cin>>tc;
  47. assert(tc >= 1 and tc <= 50);
  48. vector <int> ans;
  49. while(tc--){
  50. int n; string s;
  51. cin>>n>>s;
  52. int l = s.length();
  53. assert(n >= 1 and n <= bara);
  54. assert(l >= 1 and tc <= 100000);
  55. if(n <= l) {ans.pb(0); continue;}
  56. int res = (modpow(26ll, n - l, MOD)%MOD + (25ll * (l * modpow(26ll, n - l - 1, MOD))%MOD)%MOD)%MOD;
  57. ans.pb(res);
  58. }
  59. // cout<<"*********************"<<endl;
  60. for(auto z : ans) cout<<z<<endl;
  61. return 0;
  62. }
Success #stdin #stdout 0s 15240KB
stdin
1
2 ab
stdout
0