diff --git a/Hard/Day3/Solution.cpp b/Hard/Day3/Solution.cpp index e69de29..d466b32 100644 --- a/Hard/Day3/Solution.cpp +++ b/Hard/Day3/Solution.cpp @@ -0,0 +1,124 @@ +// #include +// using namespace std; +// #define int long long int +// #define ff(n) for(int i=0;i> +// #define mapp map +// #define vi vector +// #define count int cnt=0; +// #define array {int n; cin>>n;int a[n];ff(n) cin>>a[i];} +// #define ipn {int n; cin>>n;} + + + + + +// const int N = 1e5 + 10; +// const int mod = 1e9 + 7; + +// int power(int a, int b) { +// int res = 1; +// while (b > 0) { +// if (b & 1) +// res = (res * a)%mod; +// a = (a * a)%mod; +// (b >>= 1)%mod; +// } +// return res%mod; +// } + +// void solve() +// { +// int n; +// cin>>n; +// int k; +// cin>>k; +// int chk = power(n,k)%mod; +// int ans = chk%mod; +// cout<>t; +// // cout< + +using namespace std; + +const int mod = 1e9 + 7; +const int N = 2e6 + 10; + +int fact[N], infact[N]; + +int qmi(int a, int b) +{ + int res = 1; + while(b) + { + if(b & 1) res = (int)res * a % mod; + a = (int)a * a % mod; + b >>= 1; + } + return res; +} + +void init() +{ + fact[0] = 1, infact[0] = 1; + for(int i = 1; i < N; ++i) + { + fact[i] = (int)fact[i - 1] * i % mod; + infact[i] = (int)infact[i - 1] * qmi(i, mod - 2) % mod; + } +} + +int C(int a, int b) +{ + return (int)fact[a] * infact[b] % mod * infact[a - b] % mod; +} + +int main() +{ + int k; + string s; + cin >> k >> s; + + int len = s.length(); + int n = k + len; + init(); + + int ans = 0; + for(int i = len; i <= n; i++) + { + int t = (int)C(i - 1, len - 1) * qmi(25, i - len) % mod * qmi(26, n - i) % mod; + ans = (ans % mod + t % mod) % mod; + } + cout << ans << endl; + return 0; +} \ No newline at end of file