Submission #234526

#TimeUsernameProblemLanguageResultExecution timeMemory
234526shayan_pLjetopica (COI19_ljetopica)C++14
17 / 100
7 ms1152 KiB
// Never let them see you bleed... #include<bits/stdc++.h> #define F first #define S second #define PB push_back #define sz(s) int((s).size()) #define bit(n,k) (((n)>>(k))&1) using namespace std; typedef long long ll; typedef pair<int,int> pii; const int maxn = 1e5 + 10, mod = 1e9 + 7, inf = 1e9 + 10; int fac[maxn], ifac[maxn]; int Pow(int a, int b){ int ans = 1; for(; b; b>>=1, a = 1ll * a * a % mod) if(b & 1) ans = 1ll * ans * a % mod; return ans; } int C(int n, int k){ if(n < 0 || k < 0 || n < k) return 0; return 1ll * fac[n] * ifac[k] %mod * ifac[n-k] % mod; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(); fac[0] = 1; for(int i = 1; i < maxn; i++) fac[i] = 1ll * i * fac[i-1] % mod; ifac[maxn-1] = Pow(fac[maxn-1], mod-2); for(int i = maxn-2; i >= 0; i--) ifac[i] = 1ll * ifac[i+1] * (i+1) % mod; int n, k; cin >> n >> k; string s, A, B; cin >> s >> A >> B; int num = 1; for(int i = 0; i < n; i++) num = 2ll * num % mod; int tw = 1ll * num * ifac[2] % mod; num--; return cout << 1ll * C(n-1, k) * (num + tw) % mod << "\n", 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...