fork(2) download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. const int NCR_MAX = 5009;
  6. const int MD = 1e9 + 7;
  7. const int MAXN = 5009;
  8.  
  9. long long C[NCR_MAX][NCR_MAX], ans[MAXN], powArr[MAXN];
  10. long long stringsToThis[MAXN];
  11.  
  12. void ncrInit(){
  13. for(int i=0; i<NCR_MAX; i++){
  14. C[i][0]=1;
  15. for(int j=1; j<=i; j++){
  16. C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MD;
  17. }
  18. }
  19. }
  20.  
  21. int main(int argc, char const *argv[]){
  22.  
  23. int cases;
  24. scanf("%d", &cases);
  25.  
  26. ncrInit();
  27. powArr[0] = 1;
  28. for(int i=1; i<MAXN; i++) {
  29. powArr[i] = 1LL * powArr[i-1] * 25 % MD;
  30. }
  31.  
  32. for(int n=1; n<=5000; n++) {
  33. long long temp = 0;
  34. for(int i = 1; i <= n; i++) {
  35. long long ofThisLen = 26LL * powArr[i-1] % MD;
  36. stringsToThis[i] = (stringsToThis[i] + C[n-i+i-1][i-1]) % MD;
  37. temp = (temp + 1LL * ofThisLen * stringsToThis[i] % MD * stringsToThis[i] % MD) % MD;
  38. }
  39. ans[n] = temp;
  40. }
  41.  
  42. while(cases--) {
  43. int n;
  44. scanf("%d", &n);
  45. printf("%lld\n", ans[n]);
  46. }
  47. return 0;
  48. }
Runtime error #stdin #stdout 2.69s 199616KB
stdin
Standard input is empty
stdout
Standard output is empty