fork(1) download
  1. // There is nothing in a caterpillar that tells you its going to be a butterfly --------------------- !
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. #define rep(i,n) for(int i=0;i<n;i++)
  5. #define ll long long int
  6. #define pi pair<int,int>
  7. #define pii pair<ll,pi>
  8. #define f first
  9. #define mp make_pair
  10. #define mod 1000000007
  11. #define s second
  12. #define pb push_back
  13. ll pw[5111];
  14. ll fact[5111];
  15. ll ifact[5111];
  16. ll bpow(ll x,ll n){
  17. ll ans=1;
  18. while(n>0){
  19. if(n&1) ans*=x;
  20. x*=x;
  21. ans%=mod;
  22. x%=mod;
  23. n/=2;
  24. }
  25. return ans;
  26. }
  27. ll C(int n,int r){
  28. ll ret=fact[n];
  29. ret*=ifact[r];
  30. ret%=mod;
  31. ret*=ifact[n-r];
  32. ret%=mod;
  33. return ret;
  34. }
  35. int main(){
  36. int t;
  37. cin >> t;
  38. pw[0]=1;
  39. fact[0]=1;
  40. ifact[0]=1;
  41. for(ll i=1;i<=5001;i++){
  42. pw[i]=25LL*pw[i-1];
  43. pw[i]%=mod;
  44. fact[i]=i*fact[i-1];
  45. fact[i]%=mod;
  46. ifact[i]=bpow(fact[i],mod-2);
  47. }
  48. while(t--){
  49. int N;
  50. cin >> N;
  51. ll ans=0;
  52. for(int L=1;L<=N;L++){
  53. ll P=C(N,L);
  54. P*=P;
  55. P%=mod;
  56.  
  57. ll R=26LL*pw[L-1];
  58. R%=mod;
  59. R*=P;
  60. R%=mod;
  61. ans+=R;
  62. ans%=mod;
  63. }
  64. cout<<ans<<"\n";
  65. }
  66. }
  67.  
Runtime error #stdin #stdout 0.01s 3580KB
stdin
Standard input is empty
stdout
Standard output is empty