prompt
string
response
string
Problem: Sagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys: * Each child has a lovely set of toys that he loves to play with. He requests the toys one after another at distinct moments of time. A child starts playing i...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } int child, toys, scenes, queries; vector<int> vec[123456]; int parent[123456], custodyBy[123456], subtree[123456], vis[123456], roox[123456], tin[123456], tout[123456]; int tim =...
Problem: Sagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys: * Each child has a lovely set of toys that he loves to play with. He requests the toys one after another at distinct moments of time. A child starts playing i...
#include <bits/stdc++.h> using namespace std; int n, m, k, q; vector<vector<int> > graph; vector<int> toy; vector<int> child; vector<int> tin, tout; vector<int> sub; int tim = 0; void preprocess(void) { return; } void dfs(int cur, int p) { tin[cur] = tim++; sub[cur] = 1; for (int i = 0; i < (int)graph[cur].size()...
Problem: Sagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys: * Each child has a lovely set of toys that he loves to play with. He requests the toys one after another at distinct moments of time. A child starts playing i...
#include <bits/stdc++.h> using namespace std; int n, m, k, q; vector<int> bro[100005]; int ck[100005], own[100005]; int a, b; int in[100005], out[100005], yo[100005], ans[100005]; int _time; void dfs(int u) { in[u] = ++_time; ans[u] = 1; for (int i = 0; i < bro[u].size(); i++) dfs(bro[u][i]), ans[u] += ans[br...
Problem: Sagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys: * Each child has a lovely set of toys that he loves to play with. He requests the toys one after another at distinct moments of time. A child starts playing i...
#include <bits/stdc++.h> using namespace std; inline void err(istringstream *iss) {} template <typename T, typename... Args> void err(istringstream *iss, const T &$val, const Args &...args) { string $name; *iss >> $name; if ($name.back() == ',') $name.pop_back(); cout << $name << " = " << $val << "; ", err(iss,...
Problem: Sagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys: * Each child has a lovely set of toys that he loves to play with. He requests the toys one after another at distinct moments of time. A child starts playing i...
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class Div2_417D { static ArrayList<I...
Problem: Sagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys: * Each child has a lovely set of toys that he loves to play with. He requests the toys one after another at distinct moments of time. A child starts playing i...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 7, M = 2 * N; int edge[M], succ[M], ver[N], idx; int in[N], out[N], time_stamp; int fnl[N]; void add(int u, int v) { edge[idx] = v; succ[idx] = ver[u]; ver[u] = idx++; } void dfs(int u, int fa = -1) { in[u] = ++time_stamp; for (int i = ver[u]; ...
Problem: Sagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys: * Each child has a lovely set of toys that he loves to play with. He requests the toys one after another at distinct moments of time. A child starts playing i...
#include <bits/stdc++.h> using namespace std; const long long MAXN = 1e5 + 100; vector<long long> L[MAXN]; long long ingree[MAXN]; long long lvl[MAXN]; long long comp[MAXN]; long long contg = 0; long long st[MAXN]; long long lt[MAXN]; long long sz[MAXN]; long long contdfs = 0; void DFS(long long nodo) { st[nodo] = ++...
Problem: Sagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys: * Each child has a lovely set of toys that he loves to play with. He requests the toys one after another at distinct moments of time. A child starts playing i...
#include <bits/stdc++.h> using namespace std; long long pwr(long long base, long long p, long long mod = (1000000007LL)) { long long ans = 1; while (p) { if (p & 1) ans = (ans * base) % mod; base = (base * base) % mod; p /= 2; } return ans; } long long gcd(long long a, long long b) { if (b == 0) r...
Problem: Sagheer is working at a kindergarten. There are n children and m different toys. These children use well-defined protocols for playing with the toys: * Each child has a lovely set of toys that he loves to play with. He requests the toys one after another at distinct moments of time. A child starts playing i...
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; /** * @author Don Li */ public class SagheerKindergarten { int[][] G; boolean[] vis; int timer = 0; int[] tin, ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long qpow(long long a, long long b) { long long ans = 1; while (b) { if (b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; } return ans; } int main() { long long n, m; scanf("%lld%lld", &n, &m); long long ans...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int Inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3fll; const int jt = 1000000007; void inline add(int &a, int b) { a += b - jt; a += (a >> 31) & jt; } void inline sub(int &a, int b) { a -= b; a += (a >> 31) & jt; } void inline mul(int &a, int b) { a...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; long long read() { long long __x = 0, __y = 1; char __c = ' '; while (__c < '0' || __c > '9') { __c = getchar(); if (__c == '-') { __c = getchar(); break; } } while (__c >= '0' && __c <= '9') __x = __x * 10 + __c - '0', __c = getchar(); r...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
MOD = 10 ** 9 + 7 n, m = input().split(' ') n = int(n) m = int(m) ans = pow(2 * (n + 1), m, MOD) ans = (ans * (n + 1 - m)) % MOD ans = (ans * pow(n + 1, MOD - 2, MOD)) % MOD print(ans)
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; long long K = 1000000007; long long gcd(long long a, long long b, long long& x, long long& y) { if (a == 0) { x = 0; y = 1; return b; } long long x1, y1; long long d = gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return d; } int32_t main()...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; long long pwr(long long base, long long p, long long mod = (1000000007LL)) { long long ans = 1; while (p) { if (p & 1) ans = (ans * base) % mod; base = (base * base) % mod; p /= 2; } return ans; } long long gcd(long long a, long long b) { if (b == 0) r...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int Mxxx = 1e5; inline char gc() { static char buf[Mxxx], *p1 = buf, *p2 = buf; return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, Mxxx, stdin), p1 == p2) ? EOF : *p1++; } inline char pc(char ch, bool fl = false) { static char buf[Mxxx...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; int n, m, sum; int pow(int x, int k) { for (sum = 1; k; k >>= 1, x = 1LL * x * x % 1000000007) if (k & 1) sum = 1LL * sum * x % 1000000007; return sum; } int main() { scanf("%d%d", &n, &m); printf("%d\n", 1LL * pow(n + 1, m - 1) * (n - m + 1) % 1000000007 * ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; int read() { int x = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); return x * f; } void print(int x) { if (x < 0) { putc...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; int n, m; long long f[maxn]; long long qpow(long long x, long long y) { long long res = 1; while (y) { if (y & 1) res = res * x % 1000000007; x = x * x % 1000000007; y >>= 1; } return res; } int main() { scanf("%d%d", &n, &m),...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int fpow(int x, int y) { int ans = 1; while (y) { if (y & 1) ans = 1ll * ans * x % mod; x = 1ll * x * x % mod; y /= 2; } return ans; } int n, m; int main() { scanf("%d%d", &n, &m); printf("%lld\n", 1ll * fpow(2 * (n + 1), m) ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> namespace Main { namespace Source { static inline const unsigned int qpow(unsigned int b, unsigned int e, const unsigned int mod) { unsigned int r(1); while (e) { if (e bitand 1) r = 1ull * r * b % mod; b = 1ull * b * b % mod, e >>= 1; } ret...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> const int mu = 1e9 + 7; int n, m; int ksm(int x, int y) { x = x % mu; int ans = 1; for (; y; y >>= 1, x = (long long)x * x % mu) if (y & 1) ans = (long long)ans * x % mu; return ans; } int main() { scanf("%d%d", &n, &m); int ans = ksm(2 * (n + 1), m); ans = (long long)ans * (n...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> inline long long read() { long long x = 0, f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) { x = (x << 1) + (x << 3) + ch - '0'; ch = getchar(); } return x * f; } const long long mod = 1e9 + 7; long lo...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while (!isdigit(c)) { if (c == '-') f = -1; c = getchar(); } while (isdigit(c)) { x = x * 10 + c - '0', c = getchar(); } return x * f; } const int mod = 1e9 + 7; int pow(int a, int b) { in...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; long long n, m; inline long long qpow(long long x, long long k) { long long base = x; long long ret = 1; while (k) { if (k & 1) ret = ret * base % MOD; base = base * base % MOD; k >>= 1; } return ret; } signed main() { ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; void err(istream_iterator<string> it) { cerr << endl; } template <typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << " , "; err(++it, args...); } const int mod = 1e9 + 7; long long qp(long long b, long l...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; int n, m; const int MOD = 1e9 + 7; long long qpow(long long a, long long b) { long long ans = 1; while (b > 0) { if (b & 1) ans = ans * a % MOD; a = (a * a) % MOD; b >>= 1; } return ans; } int main() { scanf("%d%d", &n, &m); printf("%lld\n", ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int n, m; inline int fpow(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 main() { cin >> n >> m; int p = 1ll * (n + 1 - m) * fpow(n + 1, mod - 2) % mod; in...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; namespace mine { long long qread() { long long ans = 0, f = 1; char c = getchar(); while (c < '0' or c > '9') { if (c == '-') f = -1; c = getchar(); } while ('0' <= c and c <= '9') ans = ans * 10 + c - '0', c = getchar(); return ans * f; } void write(lon...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int Pow(register int a, register int x, register int ans = 1) { for (; x; x >>= 1, a = 1ll * a * a % mod) if (x & 1) ans = 1ll * ans * a % mod; return ans; } int main() { int n, m; scanf("%d%d", &n, &m); printf("%lld\n", 1ll * (n + 1 -...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; inline void Read(int &x) { int f = 1; char c = getchar(); x = 0; while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 3) + (x << 1) + c - '0'; c = getchar(); } x *= f; } const int p = 10...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int p = 1e9 + 7; int ksm(int a, int b, int p) { int ans = 1; while (b) { if (b & 1) ans = 1ll * ans * a % p; b >>= 1, a = 1ll * a * a % p; } return ans; } int main() { ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int n, m; cin >> n >> m; ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; namespace thecold { const int jzp = 1e9 + 7; int n, m; inline int quickpow(long long x, long long y) { long long ret = 1; while (y) { if (y & 1) ret = ret * x % jzp; x = x * x % jzp, y >>= 1; } return ret; } inline void main() { scanf("%d %d", &n, &m); i...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const long long MOD = 1e9 + 7; void read(long long &s) { s = 0; bool pd = false; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') pd = true; c = getchar(); } while (c >= '0' && c <= '9') { s = (s << 3) + (s << 1) + (c ^ 48); c = get...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; int main() { long long ans = 2, n, m; scanf("%lld%lld", &n, &m); for (int i = 1; i <= m - 1; i++) ans = ans * 2 * (n + 1) % mod; ans = ans * (n + 1 - m) % mod; printf("%lld", ans); return 0; }
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; bool home = 1; signed realMain(); signed main() { home = 0; if (home) { freopen("tony_stark", "r", stdin); } else { ios::sync_with_stdio(0); cin.tie(0); } realMain(); } const long long M = (long long)1e9 + 7; long long pw(long long a, long long b) { ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int n, m; inline int mpow(int a, int x) { int ans = 1; while (x) { if (x & 1) ans = 1ll * ans * a % mod; a = 1ll * a * a % mod; x >>= 1; } return ans; } int main() { scanf("%d %d", &n, &m); printf("%lld\n", 1ll * mpow(2 * (n ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long ksm(long long x, long long y) { long long res = 1; while (y) { if (y & 1) res = res * x % mod; x = x * x % mod; y >>= 1; } return res; } int main() { long long n, m; cin >> n >> m; cout << ((n + 1 - m) * ksm...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; inline void Read(int &x) { int f = 1; char c = getchar(); x = 0; while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 3) + (x << 1) + c - '0'; c = getchar(); } x *= f; } const int p = 10...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; inline void Read(int &x) { int f = 1; char c = getchar(); x = 0; while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 3) + (x << 1) + c - '0'; c = getchar(); } x *= f; } const int p = 10...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int n, m; template <typename Tp> void read(Tp &x) { x = 0; int f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = get...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; int read() { int X = 0, w = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') w = -1; c = getchar(); } while (c >= '0' && c <= '9') X = X * 10 + c - '0', c = getchar(); return X * w; } const int mod = 1e9 + 7; int qpow(int a, int b) { i...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; int read() { int v = 0, f = 1; char c = getchar(); while (c < 48 || 57 < c) { if (c == '-') f = -1; c = getchar(); } while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar(); return v * f; } const long long MOD = 1000000007; long long n, m...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long quickpow(long long x, long long n) { long long y = 1; while (n) { if (n & 1) y = y * x % mod; n >>= 1; x = x * x % mod; } return y; } long long n, m; int main() { scanf("%lld %lld", &n, &m); printf("%lld", qui...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; const int M = 300005; long long read() { long long ans = 0, op = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') op = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { ans *= 10; ans += ch -...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> template <class T> inline T read(const T sample) { T x = 0; int f = 1; char s; while ((s = getchar()) > '9' || s < '0') if (s == '-') f = -1; while (s >= '0' && s <= '9') x = (x << 1) + (x << 3) + (s ^ 48), s = getchar(); return x * f; } template <class T> inline void write(...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; inline long long quick(long long mul, long long b) { long long c = 1; while (b) { if (b & 1) { c = c * mul % mod; } mul = mul * mul % mod; b /= 2; } return c; } int main() { long long n, m; cin >> n >> m; co...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int MOD = 1000000007; int N, M; long long power(long long a, long long b) { if (b == 0) return 1; if (b == 1) return a; if (b % 2 == 0) return power(a * a % MOD, b / 2); return a * power(a * a % MOD, (b - 1) / 2) % MOD; } int main() { cin >> N >> M; long l...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; int n, m; int qp(int a, int b) { int c = 1; for (; b; b >>= 1, a = 1ll * a * a % 1000000007) if (b & 1) c = 1ll * c * a % 1000000007; return c; } int main() { scanf("%d%d", &n, &m); printf("%lld\n", 1ll * qp(2 * (n + 1), m) * (n + 1 - m) % 1000000007 * ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int Pow(int x, int p) { int r = 1; while (p) { if (p & 1) r = (long long)x * r % mod; x = (long long)x * x % mod; p >>= 1; } return r; } int main() { int n, m; scanf("%d %d", &n, &m); cout << (long long)Pow(n + 1, mod - 2) ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 10, mod = 1e9 + 7; const long long inf = 1e18; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> m >> n; int ans = m + 1 - n; for (int i = 0; i < n - 1; i++) ans = 1ll * ans * (m + 1) % mod; for (int i = 0; i < ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; long long ModExp(long long a, long long n) { long long ans = 1; a %= 1000000007; while (n) { if (n % 2) ans = (ans * a) % 1000000007; a = (a * a) % 1000000007; n /= 2; } return ans; } int main() { long long n, m, ans; cin >> n >> m; ans = ModExp(...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } const int mod = 1e9 + 7...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int pow(int x, int k) { int sum = 1; while (k) { if (k & 1) { sum = 1LL * sum * x % mod; } x = 1LL * x * x % mod; k >>= 1; } return sum; } int main() { int n, m; scanf("%d%d", &n, &m); printf("%d\n", 1LL * pow(...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; long long n, m, ans = 1; signed main() { cin >> n >> m; for (long long i = 1; i <= m; i++) ans = ans * 2 % 1000000007; for (long long i = 1; i < m; i++) ans = ans * (n + 1) % 1000000007; ans = ans * (n + 1 - m) % 1000000007; cout << ans; }
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; int n, m; long long po(long long b, int p) { long long re = 1; while (p) { if (p & 1) re = re * b % 1000000007; b = b * b % 1000000007; p >>= 1; } return re; } int main() { scanf("%d%d", &n, &m); printf("%lld\n", po(2, m) * po(n + 1, m - 1) ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int Power(int x, int y) { int r = 1; while (y) { if (y & 1) r = 1ll * r * x % mod; y >>= 1, x = 1ll * x * x % mod; } return r; } int n, m; int main() { cin >> n >> m; cout << 1ll * (n + 1 - m) % mod * Power(n + 1, mod - 2) % mod ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; int n, m; const int mod = 1e9 + 7; int ksm(int x, int y = mod - 2) { int z = 1; for (; y; y >>= 1, x = 1ll * x * x % mod) if (y & 1) z = 1ll * z * x % mod; return z; } int main() { scanf("%d%d", &n, &m); printf("%d\n", 1ll * ksm(2, m) * ksm(n + 1, m - 1) % mod...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const int P = 1e9 + 7; inline int read() { char a = getchar(); int x = 0, f = 1; for (; a > '9' || a < '0'; a = getchar()) if (a == '-') f = -1; for (; a >= '0' && a <= '9'; a = getchar()) x = x * 10 + a - '0'; return x * f; } inlin...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int MOD = (1e9) + 7; int n, m; int fpow(int a, int b) { if (a == 0) return 0; if (b == 0) return 1; int p = fpow(a, b >> 1); p = p * 1ll * p % MOD; if (b & 1) p = p * 1ll * a % MOD; return p; } int div_mod(int a, int b) { return a * 1ll * fpow(b, MOD - 2) ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
n,m=[int(i) for i in input().split()] print(pow(2*n+2,m-1,1000000007)*2*(n+1-m)%1000000007)
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int Mod = 1e9 + 7; int fpow(int x, int y) { int res = 1; while (y) { if (y & 1) res = 1ll * res * x % Mod; x = 1ll * x * x % Mod, y >>= 1; } return res; } int N, M; int main() { cin >> N >> M; cout << 2ll * (N + 1 - M) * fpow(2 * (N + 1), M - 1) % ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const long long maxn = 1e5 + 5, mod = 1e9 + 7, inf = 0x3f3f3f3f; long long n, m, Q, K, T; long long read() { long long x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> template <typename T> inline void rd(T& x) { int si = 1; char c = getchar(); x = 0; while (!isdigit(c)) si = c == '-' ? -1 : si, c = getchar(); while (isdigit(c)) x = x * 10 + c - 48, c = getchar(); x *= si; } template <typename T, typename... Args> inline void rd(T& x, Args&... arg...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; inline int read() { char c; int res = 0, f = 1; while (c = getchar(), !isdigit(c)) if (c == '-') f *= -1; while (isdigit(c)) res = res * 10 + c - '0', c = getchar(); return res * f; } const long long mod = 1e9 + 7; long long n, m; inline long long lpow(long lo...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; inline long long read() { long long f = 1, ans = 0; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { ans = ans * 10 + c - '0'; c = getchar(); } return f * ans; } long long N,...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> const int mod = 1000000007; inline int power(int a, int b) { int ans = 1; for (; b; b >>= 1) { if (b & 1) ans = (long long)ans * a % mod; a = (long long)a * a % mod; } return ans; } int main() { int n, m; scanf("%d%d", &n, &m); printf("%lld\n", (long long)(n - m + 1) * pow...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; long long gi() { char cc = getchar(); long long cn = 0, flus = 1; while (cc < '0' || cc > '9') { if (cc == '-') flus = -flus; cc = getchar(); } while (cc >= '0' && cc <= '9') cn = cn * 10 + cc - '0', cc = getchar(); return cn * flus; } const long long P ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
mod = 10 ** 9 + 7 n , m = map(int , raw_input().split()) print (pow(2 * (n + 1) , m - 1 , mod) * (n + 1 - m) * 2) % mod
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; int n, m; int ksm(int a, int b) { int x = 1; for (; b; b& 1 ? x = 1ll * x * a % mod : 0, a = 1ll * a * a % mod, b >>= 1) ; return x; } int main() { cin >> n >> m; cout << 1ll * ksm(2, m) * ksm(n + 1, m) % mod * (n + 1 - m) % mod * ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; inline void Read(int &x) { int f = 1; char c = getchar(); x = 0; while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 3) + (x << 1) + c - '0'; c = getchar(); } x *= f; } const int p = 10...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> const int INF = 1 << 29; int cmp(const void* a, const void* b); long long maxv(long long a, long long b); long long minv(long long a, long long b); long long gcd(long long u, long long v); long long binpow(long long a, long long b, long long m) { long long res = 1; a = a % m; while (b > 0...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int N = 500 + 10; const int p = 1e9 + 7; long long f[N], dp[N][N], C[N][N]; long long fpow(register long long a, register long long b) { register long long res = 1; for (; b; b >>= 1, a = a * a % p) if (b & 1) res = res * a % p; return res; } int main() { ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; template <class T> inline void read(T &x) { int f = 0; x = 0; char ch = getchar(); for (; !isdigit(ch); ch = getchar()) f |= (ch == '-'); for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0'; if (f) x = -x; } const int mod = 1e9 + 7; int power(int x, int p)...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; inline int read() { int x = 0; char ch = getchar(); while (!isdigit(ch)) ch = getchar(); while (isdigit(ch)) { x = x * 10 + ch - '0'; ch = getchar(); } return x; } inline int qpow(int x, int y = MOD - 2) { long long r = 1, k = ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; template <typename T> inline bool chkmin(T &x, T y) { return (y < x) ? (x = y, 1) : 0; } template <typename T> inline bool chkmax(T &x, T y) { return (y > x) ? (x = y, 1) : 0; } inline int read() { int x; char c; int f = 1; while ((c = getchar()) != '-' && (c > ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int Mod = 1e9 + 7; int Quick_Mod(int a, int k) { int x = 1; for (; k; k >>= 1) { if (k & 1) { x = 1ll * x * a % Mod; } a = 1ll * a * a % Mod; } return x; } int main() { int n, m; scanf("%d%d", &n, &m); ++n; int ans = 1ll * Quick...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; template <typename Tp> inline int getmin(Tp &x, Tp y) { return y < x ? x = y, 1 : 0; } template <typename Tp> inline int getmax(Tp &x, Tp y) { return y > x ? x = y, 1 : 0; } template <typename Tp> inline void read(Tp &x) { x = 0; int f = 0; ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7; long long n, m; long long qpow(long long a, long long exp) { long long ans = 1; while (exp) { if (exp & 1) ans = ans * a % mod; a = a * a % mod; exp >>= 1; } return ans; } signed main() { ios_base::sync_with_stdio(0); c...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; inline long long read() { long long res = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { res = res * 10 + c - '0'; c = getchar(); } return res * f; } const long l...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; int read() { int x = 0; int f = 1; char ch = getchar(); while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); } while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar(); return x * f; } void print(int x) { if (x < 0) { putc...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long power(long long base, long long b) { long long ret = 1; while (b) { if (b & 1) ret = ret * base % mod; base = base * base % mod; b >>= 1; } return ret; } long long n, m; int main() { scanf("%lld%lld", &n, &m); print...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int Maxx = 1000001, Maxn = 2001, INF = 0x3f3f3f3f, Mod = 1e9 + 7; inline int read() { int res = 0, bj = 0; char ch = getchar(); while (ch < '0' || ch > '9') bj |= (ch == '-'), ch = getchar(); while (ch >= '0' && ch <= '9') res = (res << 3) + (res << 1) + (...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; long long n, m; inline int read() { int x = 0, w = 0; char ch = 0; while (!isdigit(ch)) { w |= ch == '-'; ch = getchar(); } while (isdigit(ch)) { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); } return w ? -x :...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; long long n, m; long long qp(long long x, int t) { long long res = 1; for (; t; t >>= 1, x = x * x % mod) if (t & 1) res = res * x % mod; return res; } int main() { scanf("%lld %lld", &n, &m); long long ans = qp(2 * n + 2, m) * (...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; long long modpow(long long a, long long b) { if (!b) return 1; else { long long z = modpow(a, b / 2); z = (z * z) % 1000000007; if (b % 2) return (a * z) % 1000000007; else return z; } } int main() { long long m, n; cin >> n >> m; ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; long long n, m; long long qpow(long long a, long long b) { if (!b) return 1; long long tmp = qpow(a, b / 2); return b % 2 ? tmp * tmp % 1000000007 * a % 1000000007 : tmp * tmp % 1000000007; } signed main() { cin >> n >> m; cout << (n + 1 - m) * qpow...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; inline void Read(int &x) { int f = 1; char c = getchar(); x = 0; while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 3) + (x << 1) + c - '0'; c = getchar(); } x *= f; } const int p = 10...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int p = 1e9 + 7; inline int qpow(int a, int b) { int ans = 1; for (; b; b >>= 1, a = 1ll * a * a % p) if (b & 1) ans = 1ll * ans * a % p; return ans; } int main() { int n, m; scanf("%d%d", &n, &m); n++; printf("%d\n", 1ll * qpow(n << 1, m) * (n - m) ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; int read() { int ans = 0, flag = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') flag = -flag; ch = getchar(); } while (ch >= '0' && ch <= '9') { ans = ans * 10 + ch - '0'; ch = getchar(); } return ans * flag; } const int ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; inline int add(int a, int b) { if ((a += b) >= mod) a -= mod; return a; } inline int mult(int a, int b) { long long t = 1ll * a * b; if (t >= mod) t %= mod; return t; } inline int power(int a, int b) { int out = 1; while (b) { i...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 10, mod = 1e9 + 7; int n, m; long long qpow(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = res * a % mod; b >>= 1; a = a * a % mod; } return res; } int main() { scanf("%d%d", &n, &m); long long ans = ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; inline void Read(int &x) { int f = 1; char c = getchar(); x = 0; while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 3) + (x << 1) + c - '0'; c = getchar(); } x *= f; } const int p = 10...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; inline void Read(int &x) { int f = 1; char c = getchar(); x = 0; while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') { x = (x << 3) + (x << 1) + c - '0'; c = getchar(); } x *= f; } const int p = 10...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; void hk() {} long long solve(long long x, int k) { long long t = 1; for (; k; k >>= 1, x = x * x % (1000000007)) if (k & 1) t = t * x % (1000000007); return t; } int main() { { int n, m; cin >> n >> m; long long res = 1ll * solve(2, m) * solve(n + 1,...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> long long qkpow(long long x, long long y) { long long ans = 1; while (y) { if (y & 1) ans = ans * x % 1000000007; x = x * x % 1000000007; y >>= 1; } return ans; } signed main() { long long n, m; scanf("%lld %lld", &n, &m); printf("%lld\n", (n + 1 - m) * qkpow(2 * (n + ...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const int N = 300 * 1000 + 10, mod = 1e9 + 7; long long t2[N], cnt[N]; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); long long ans = 1; long long n, m; cin >> n >> m; for (int i = 0; i < m - 1; i++) ans *= 2 * n + 2, ans %= mod; ans *= n + 1 - m; ans...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; int reiz(int a, int b) { return (1LL * a * b) % ((int)1e9 + 7); } int power(int n, int k) { if (k == 0) return 1; int l = power(n, k / 2); if (k % 2 == 0) return reiz(l, l); if (k % 2 == 1) return reiz(reiz(l, l), n); } int main() { int n, m; cin >> n >> m; co...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> #pragma warning(disable : 4996) #pragma comment(linker, "/STACK:33554432") using namespace std; int IT_MAX = 1 << 18; const long long MOD = 1000000007; const int INF = 0x3f3f3f3f; const long long LL_INF = 0x3f3f3f3f3f3f3f3f; const double PI = acos(-1); const double ERR = 1e-10; int main() { l...
Problem: There is an airplane which has n rows from front to back. There will be m people boarding this airplane. This airplane has an entrance at the very front and very back of the plane. Each person has some assigned seat. It is possible for multiple people to have the same assigned seat. The people will then boar...
#include <bits/stdc++.h> using namespace std; const long long mod = 1000000007; long long n, m; inline long long pw(long long a, long long b) { long long res = 1; while (b) { if (b & 1) res = res * a % mod; b >>= 1; a = a * a % mod; } return res; } signed main() { scanf("%lld%lld", &n, &m); prin...