A - Ice Tea Store

算一下每种零售最少的钱就行,然后优先买2,零头买1

  1. #include <bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define pii pair<int,int>
  5. #define mp make_pair
  6. #define pb push_back
  7. #define space putchar(' ')
  8. #define enter putchar('\n')
  9. #define MAXN 100005
  10. #define eps 1e-12
  11. //#define ivorysi
  12. using namespace std;
  13. typedef long long int64;
  14. typedef unsigned int u32;
  15. typedef double db;
  16. template<class T>
  17. void read(T &res) {
  18. res = 0;T f = 1;char c = getchar();
  19. while(c < '0' || c > '9') {
  20. if(c == '-') f = -1;
  21. c = getchar();
  22. }
  23. while(c >= '0' && c <= '9') {
  24. res = res * 10 + c - '0';
  25. c = getchar();
  26. }
  27. res *= f;
  28. }
  29. template<class T>
  30. void out(T x) {
  31. if(x < 0) {x = -x;putchar('-');}
  32. if(x >= 10) {
  33. out(x / 10);
  34. }
  35. putchar('0' + x % 10);
  36. }
  37. int Q,H,S,D,N;
  38. int64 ans;
  39. int main() {
  40. read(Q);read(H);read(S);read(D);
  41. read(N);
  42. H = min(2 * Q,H);
  43. S = min(2 * H,S);
  44. D = min(2 * S,D);
  45. ans = 1LL * (N / 2) * D + (N & 1) * S;
  46. out(ans);enter;
  47. }

B - Reverse and Compare

对于两个相同的字符,在这个字符之间的翻转肯定能取代以这两个字符为端点的翻转

那么如果认为一个翻转会形成一个字符串,那么我们删掉左右两端点相同的翻转

  1. #include <bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define pii pair<int,int>
  5. #define mp make_pair
  6. #define pb push_back
  7. #define space putchar(' ')
  8. #define enter putchar('\n')
  9. #define MAXN 200005
  10. #define eps 1e-12
  11. //#define ivorysi
  12. using namespace std;
  13. typedef long long int64;
  14. typedef unsigned int u32;
  15. typedef double db;
  16. template<class T>
  17. void read(T &res) {
  18. res = 0;T f = 1;char c = getchar();
  19. while(c < '0' || c > '9') {
  20. if(c == '-') f = -1;
  21. c = getchar();
  22. }
  23. while(c >= '0' && c <= '9') {
  24. res = res * 10 + c - '0';
  25. c = getchar();
  26. }
  27. res *= f;
  28. }
  29. template<class T>
  30. void out(T x) {
  31. if(x < 0) {x = -x;putchar('-');}
  32. if(x >= 10) {
  33. out(x / 10);
  34. }
  35. putchar('0' + x % 10);
  36. }
  37. int64 ans;
  38. int N,L,cnt[30];
  39. char s[MAXN];
  40. void Solve() {
  41. scanf("%s",s + 1);
  42. N = strlen(s + 1);
  43. ans = 1 + 1LL * N * (N - 1) / 2;
  44. for(int i = 1 ; i <= N ; ++i) {
  45. cnt[s[i] - 'a']++;
  46. }
  47. for(int i = 0 ; i <= 25 ; ++i) {
  48. ans -= 1LL * cnt[i] * (cnt[i] - 1) / 2;
  49. }
  50. out(ans);enter;
  51. }
  52. int main() {
  53. #ifdef ivorysi
  54. freopen("f1.in","r",stdin);
  55. #endif
  56. Solve();
  57. }

C - Fountain Walk

以横坐标上升对y求一个最长上升子序列

设长度为\(k\)

如果\(k < min(x_2 - x_1,y_2 - y_1) + 1\)

那么我就可以拐角k次,减少\((20 - 5\pi)k\)

否则我只能拐角k - 1次,不得不走一个半圆,减少\((20 - 5\pi)(k - 1)\)加上\((10\pi - 20)\)

  1. #include <bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define pii pair<int,int>
  5. #define mp make_pair
  6. #define pb push_back
  7. #define space putchar(' ')
  8. #define enter putchar('\n')
  9. #define MAXN 200005
  10. #define eps 1e-12
  11. //#define ivorysi
  12. using namespace std;
  13. typedef long long int64;
  14. typedef unsigned int u32;
  15. typedef double db;
  16. template<class T>
  17. void read(T &res) {
  18. res = 0;T f = 1;char c = getchar();
  19. while(c < '0' || c > '9') {
  20. if(c == '-') f = -1;
  21. c = getchar();
  22. }
  23. while(c >= '0' && c <= '9') {
  24. res = res * 10 + c - '0';
  25. c = getchar();
  26. }
  27. res *= f;
  28. }
  29. template<class T>
  30. void out(T x) {
  31. if(x < 0) {x = -x;putchar('-');}
  32. if(x >= 10) {
  33. out(x / 10);
  34. }
  35. putchar('0' + x % 10);
  36. }
  37. const double PI = acos(-1.0);
  38. int64 x[MAXN],y[MAXN],id[MAXN];
  39. int64 X1,X2,Y1,Y2,num[MAXN],val[MAXN];
  40. int N,tot,c;
  41. void Solve() {
  42. read(X1);read(Y1);read(X2);read(Y2);
  43. read(N);
  44. for(int i = 1 ; i <= N ; ++i) {
  45. read(x[i]);read(y[i]);
  46. }
  47. if(X1 > X2) {
  48. swap(X1,X2);swap(Y1,Y2);
  49. }
  50. if(Y1 > Y2) {
  51. swap(Y1,Y2);
  52. for(int i = 1 ; i <= N ; ++i) {
  53. y[i] = Y1 + Y2 - y[i];
  54. }
  55. }
  56. for(int i = 1 ; i <= N ; ++i) {
  57. id[i] = i;
  58. }
  59. sort(id + 1,id + N + 1,[](int a,int b){return y[a] < y[b];});
  60. for(int i = 1 ; i <= N ; ++i) {
  61. int u = id[i];
  62. if(y[u] >= Y1 && y[u] <= Y2 && x[u] >= X1 && x[u] <= X2) {
  63. num[++tot] = x[u];
  64. }
  65. }
  66. c = 0;
  67. val[c] = -1;
  68. for(int i = 1 ; i <= tot ; ++i) {
  69. if(num[i] > val[c]) val[++c] = num[i];
  70. else {
  71. int t = upper_bound(val + 1,val + c + 1,num[i]) - val;
  72. val[t] = num[i];
  73. }
  74. }
  75. if(c < min(X2 - X1,Y2 - Y1) + 1) {
  76. double ans = 100.0 * (X2 - X1 + Y2 - Y1) - (20 - PI * 5) * c;
  77. printf("%.12lf\n",ans);
  78. }
  79. else {
  80. double ans = 100.0 * (X2 - X1 + Y2 - Y1) - (20 - PI * 5) * (c - 1) + (10 * PI - 20);
  81. printf("%.12lf\n",ans);
  82. }
  83. }
  84. int main() {
  85. #ifdef ivorysi
  86. freopen("f1.in","r",stdin);
  87. #endif
  88. Solve();
  89. }

D - Shift and Flip

枚举B的第一位和A的哪一位对齐

然后对于A的每一位1,如果对着的B不是1,那么我们想办法把它消成0,这找这个1最近的两个1,这分别对应着两个和B第一位对齐的位置,放在数轴上

然后用twopoints,枚举当左边选择数轴上的点在这的时候,右边最远选到哪,计算两种走法,然后计算端点到目标点的距离

  1. #include <bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define pii pair<int,int>
  5. #define mp make_pair
  6. #define pb push_back
  7. #define space putchar(' ')
  8. #define enter putchar('\n')
  9. #define MAXN 4005
  10. #define eps 1e-12
  11. //#define ivorysi
  12. using namespace std;
  13. typedef long long int64;
  14. typedef unsigned int u32;
  15. typedef double db;
  16. template<class T>
  17. void read(T &res) {
  18. res = 0;T f = 1;char c = getchar();
  19. while(c < '0' || c > '9') {
  20. if(c == '-') f = -1;
  21. c = getchar();
  22. }
  23. while(c >= '0' && c <= '9') {
  24. res = res * 10 + c - '0';
  25. c = getchar();
  26. }
  27. res *= f;
  28. }
  29. template<class T>
  30. void out(T x) {
  31. if(x < 0) {x = -x;putchar('-');}
  32. if(x >= 10) {
  33. out(x / 10);
  34. }
  35. putchar('0' + x % 10);
  36. }
  37. int L[MAXN],R[MAXN],N;
  38. char a[MAXN],b[MAXN];
  39. vector<int> v[MAXN];
  40. int cnt[MAXN];
  41. bool checkpos(int x) {
  42. if(x >= N) return false;
  43. for(auto t : v[x]) {
  44. cnt[t]--;
  45. }
  46. bool flag = 1;
  47. for(auto t : v[x]) if(!cnt[t]) flag = 0;
  48. for(auto t : v[x]) cnt[t]++;
  49. return flag;
  50. }
  51. void Solve() {
  52. scanf("%s%s",a,b);
  53. N = strlen(a);
  54. int ca = 0,cb = 0;
  55. for(int i = 0 ; i < N ; ++i) {
  56. if(a[i] == '1') ++ca;
  57. if(b[i] == '1') ++cb;
  58. }
  59. if(!cb) {
  60. if(!ca) puts("0");
  61. else puts("-1");
  62. return;
  63. }
  64. for(int i = 0 ; i < N ; ++i) {
  65. if(a[i] == '1') {
  66. int t = i;
  67. int cnt = 0;
  68. while(b[t] == '0') {
  69. t = (t - 1 + N) % N;
  70. ++cnt;
  71. }
  72. L[i] = cnt % N;
  73. t = i,cnt = 0;
  74. while(b[t] == '0') {
  75. t = (t + 1) % N;
  76. ++cnt;
  77. }
  78. R[i] = (N - cnt) % N;
  79. }
  80. }
  81. for(int i = 0 ; i < N ; ++i) a[i + N] = a[i];
  82. int ans = 1e9;
  83. for(int i = 0 ; i < N ; ++i) {
  84. int now = 0;
  85. for(int j = 0 ; j < N ; ++j) v[j].clear();
  86. memset(cnt,0,sizeof(cnt));
  87. for(int j = 0 ; j < N ; ++j) {
  88. if(b[j] != a[i + j]) {
  89. ++now;
  90. if(a[i + j] == '1') {
  91. int t = (i + j) % N;
  92. v[L[t]].pb(t);v[R[t]].pb(t);
  93. cnt[t] += 2;
  94. }
  95. }
  96. }
  97. int p = 0,q = 1;
  98. while(p < N) {
  99. while(checkpos(q)) {
  100. for(auto t : v[q]) cnt[t]--;
  101. ++q;
  102. }
  103. int tmp = p + 2 * (N - q);
  104. tmp += min(abs(p - i),N - abs(p - i));
  105. ans = min(ans,tmp + now);
  106. tmp = N - q + 2 * p;
  107. tmp += min(abs(q - i),N - abs(q - i));
  108. ans = min(ans,tmp + now);
  109. ++p;
  110. for(auto t : v[p]) cnt[t]++;
  111. }
  112. }
  113. out(ans);enter;
  114. }
  115. int main() {
  116. #ifdef ivorysi
  117. freopen("f1.in","r",stdin);
  118. #endif
  119. Solve();
  120. }

E - Shuffle and Swap

就是对于01 和 10这两种序列配对,然后可以插任意个11进去

假如有d个01,总共k个1

这个方案数就是\((\frac{1}{1!}x^{1} + \frac{1}{2!}x^{2}.... + \frac{1}{k!}x^{k})^d\)

然后记\(f(i)\)是系数,那么方案数就是\(f(i) d!(k - d)!k!\),对于每个i都累加一下

  1. #include <bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define pii pair<int,int>
  5. #define mp make_pair
  6. #define pb push_back
  7. #define space putchar(' ')
  8. #define enter putchar('\n')
  9. #define MAXN 10005
  10. #define eps 1e-12
  11. //#define ivorysi
  12. using namespace std;
  13. typedef long long int64;
  14. typedef unsigned int u32;
  15. typedef double db;
  16. template<class T>
  17. void read(T &res) {
  18. res = 0;T f = 1;char c = getchar();
  19. while(c < '0' || c > '9') {
  20. if(c == '-') f = -1;
  21. c = getchar();
  22. }
  23. while(c >= '0' && c <= '9') {
  24. res = res * 10 + c - '0';
  25. c = getchar();
  26. }
  27. res *= f;
  28. }
  29. template<class T>
  30. void out(T x) {
  31. if(x < 0) {x = -x;putchar('-');}
  32. if(x >= 10) {
  33. out(x / 10);
  34. }
  35. putchar('0' + x % 10);
  36. }
  37. const int MOD = 998244353,MAXL = (1 << 16);
  38. char a[MAXN],b[MAXN];
  39. int N,k,d,fac[MAXN],invfac[MAXN],W[MAXL];
  40. int inc(int a,int b) {
  41. return a + b >= MOD ? a + b - MOD : a + b;
  42. }
  43. int mul(int a,int b) {
  44. return 1LL * a * b % MOD;
  45. }
  46. int C(int n,int m) {
  47. if(n < m) return 0;
  48. return mul(fac[n],mul(invfac[m],invfac[n - m]));
  49. }
  50. int fpow(int x,int c) {
  51. int res = 1,t = x;
  52. while(c) {
  53. if(c & 1) res = mul(res,t);
  54. t = mul(t,t);
  55. c >>= 1;
  56. }
  57. return res;
  58. }
  59. struct poly {
  60. vector<int> v;
  61. void limit(int n = -1) {
  62. if(n != -1) v.resize(n);
  63. while(v.size() > 1 && (v.back()) == 0) v.pop_back();
  64. }
  65. friend void NTT(poly &f,int L,int on) {
  66. f.v.resize(L);
  67. for(int i = 1, j = L >> 1 ; i < L - 1 ; ++i) {
  68. if(i < j) swap(f.v[i],f.v[j]);
  69. int k = L >> 1;
  70. while(j >= k) {
  71. j -= k;
  72. k >>= 1;
  73. }
  74. j += k;
  75. }
  76. for(int h = 2 ; h <= L ; h <<= 1) {
  77. int wn = W[(MAXL + on * MAXL / h) % MAXL];
  78. for(int k = 0 ; k < L ; k += h) {
  79. int w = 1;
  80. for(int j = k ; j < k + h / 2 ; ++j) {
  81. int u = f.v[j],v = mul(w,f.v[j + h / 2]);
  82. f.v[j] = inc(u,v);
  83. f.v[j + h / 2] = inc(u,MOD - v);
  84. w = mul(w,wn);
  85. }
  86. }
  87. }
  88. if(on == -1) {
  89. int invL = fpow(L,MOD - 2);
  90. for(int i = 0 ; i < L ; ++i) {
  91. f.v[i] = mul(f.v[i],invL);
  92. }
  93. }
  94. }
  95. friend poly operator * (poly a,poly b) {
  96. poly c;c.v.clear();
  97. int s = a.v.size() + b.v.size();
  98. int L = 1;
  99. while(L <= s) L <<= 1;
  100. NTT(a,L,1);NTT(b,L,1);
  101. for(int i = 0 ; i < L ; ++i) {
  102. c.v.pb(mul(a.v[i],b.v[i]));
  103. }
  104. NTT(c,L,-1);
  105. return c;
  106. }
  107. friend poly fpow(const poly &a,int c,int n) {
  108. poly res,t = a;
  109. res.v.clear();res.v.pb(1);
  110. while(c) {
  111. if(c & 1) {
  112. res = res * t;
  113. res.limit(n);
  114. }
  115. t = t * t;t.limit(n);
  116. c >>= 1;
  117. }
  118. return res;
  119. }
  120. }f;
  121. void Solve() {
  122. scanf("%s%s",a + 1,b + 1);
  123. N = strlen(a + 1);
  124. for(int i = 1 ; i <= N ; ++i) {
  125. if(a[i] == '1') {
  126. ++k;
  127. if(b[i] == '0') ++d;
  128. }
  129. }
  130. fac[0] = 1;
  131. for(int i = 1 ; i <= N ; ++i) {
  132. fac[i] = mul(fac[i - 1],i);
  133. }
  134. invfac[N] = fpow(fac[N],MOD - 2);
  135. for(int i = N - 1 ; i >= 0 ; --i) {
  136. invfac[i] = mul(invfac[i + 1],i + 1);
  137. }
  138. W[0] = 1;W[1] = fpow(3,(MOD - 1) / MAXL);
  139. for(int i = 2 ; i < MAXL ; ++i) W[i] = mul(W[i - 1],W[1]);
  140. f.v.clear();
  141. f.v.resize(N);
  142. for(int i = 1 ; i <= k ; ++i) {
  143. f.v[i] = invfac[i];
  144. }
  145. f = fpow(f,d,N);
  146. int ans = 0;
  147. for(int i = d ; i <= k ; ++i) {
  148. if(i > f.v.size() - 1) break;
  149. int t = mul(f.v[i],mul(fac[i],fac[d]));
  150. t = mul(t,C(k,i));
  151. t = mul(t,mul(fac[k - d],fac[k - i]));
  152. ans = inc(ans,t);
  153. }
  154. out(ans);enter;
  155. }
  156. int main() {
  157. #ifdef ivorysi
  158. freopen("f1.in","r",stdin);
  159. #endif
  160. Solve();
  161. }

F - Yes or No

本来是个组合数前缀和,但是根据递推只需要改一项???

这坐标算的也太难受了,不想说话了。。。

  1. #include <bits/stdc++.h>
  2. #define fi first
  3. #define se second
  4. #define pii pair<int,int>
  5. #define mp make_pair
  6. #define pb push_back
  7. #define space putchar(' ')
  8. #define enter putchar('\n')
  9. #define MAXN 1000005
  10. #define eps 1e-12
  11. //#define ivorysi
  12. using namespace std;
  13. typedef long long int64;
  14. typedef unsigned int u32;
  15. typedef double db;
  16. template<class T>
  17. void read(T &res) {
  18. res = 0;T f = 1;char c = getchar();
  19. while(c < '0' || c > '9') {
  20. if(c == '-') f = -1;
  21. c = getchar();
  22. }
  23. while(c >= '0' && c <= '9') {
  24. res = res * 10 + c - '0';
  25. c = getchar();
  26. }
  27. res *= f;
  28. }
  29. template<class T>
  30. void out(T x) {
  31. if(x < 0) {x = -x;putchar('-');}
  32. if(x >= 10) {
  33. out(x / 10);
  34. }
  35. putchar('0' + x % 10);
  36. }
  37. const int MOD = 998244353;
  38. int N,M;
  39. int fac[MAXN],invfac[MAXN],f[MAXN],v[MAXN],h[MAXN],inv[MAXN];
  40. int inc(int a,int b) {
  41. return a + b >= MOD ? a + b - MOD : a + b;
  42. }
  43. int mul(int a,int b) {
  44. return 1LL * a * b % MOD;
  45. }
  46. int C(int n,int m) {
  47. if(n < m) return 0;
  48. return mul(fac[n],mul(invfac[m],invfac[n - m]));
  49. }
  50. int way(int x1,int y1,int x2,int y2) {
  51. return C(x2 - x1 + y2 - y1,y2 - y1);
  52. }
  53. void update(int &x,int y) {
  54. x = inc(x,y);
  55. }
  56. int fpow(int x,int c) {
  57. int res = 1,t = x;
  58. while(c) {
  59. if(c & 1) res = mul(res,t);
  60. t = mul(t,t);
  61. c >>= 1;
  62. }
  63. return res;
  64. }
  65. void Solve() {
  66. read(N);read(M);
  67. fac[0] = 1;
  68. inv[1] = 1;
  69. for(int i = 1 ; i <= N + M ; ++i) {
  70. fac[i] = mul(fac[i - 1],i);
  71. if(i > 1) inv[i] = mul(inv[MOD % i],MOD - MOD / i);
  72. }
  73. invfac[N + M] = fpow(fac[N + M],MOD - 2);
  74. for(int i = N + M - 1 ; i >= 0 ; --i) {
  75. invfac[i] = mul(invfac[i + 1],i + 1);
  76. }
  77. if(M > N) h[0] = 1;
  78. if(N > M) v[0] = 1;
  79. for(int i = 1 ; i <= N + M ; ++i) {
  80. h[i] = h[i - 1];
  81. int r = min(i - 1,N) - h[i - 1] + 1,c = i - 1 - r + 1;
  82. if(i <= N && M - (N - r) >= c + 1) ++h[i];
  83. if(i > N && M - (N - r) <= c) --h[i];
  84. v[i] = v[i - 1];
  85. c = min(i - 1,M) - v[i - 1] + 1,r = i - 1 - c + 1;
  86. if(i <= M && N - (M - c) >= r + 1) ++v[i];
  87. if(i > M && N - (M - c) <= r) --v[i];
  88. }
  89. f[0] = mul(C(N + M, N),max(N,M));
  90. int valh = 0,valv = 0;
  91. if(h[0]) valh = C(N + M - 1, M - 1);
  92. if(v[0]) valv = C(N + M - 1, N - 1);
  93. for(int i = 1 ; i < N + M ; ++i) {
  94. f[i] = f[i - 1];
  95. if(h[i - 1]) f[i] = inc(f[i],MOD - valh);
  96. if(v[i - 1]) f[i] = inc(f[i],MOD - valv);
  97. if(!h[i - 1] && h[i]) valh = way(i,0,N,M - 1);
  98. if(!v[i - 1] && v[i]) valv = way(0,i,N - 1,M);
  99. int r1 = min(i - 1,N) - h[i - 1] + 1,c1 = i - 1 - r1;
  100. int r2 = min(i,N) - h[i] + 1,c2 = i - r2;
  101. if(h[i - 1]) {
  102. if(r2 > r1) {
  103. valh = inc(valh, MOD - mul(way(0,0,r1,c1),way(r1,c1 + 1,N,M - 1)));
  104. }
  105. else {
  106. if(r2 >= 1) valh = inc(valh,mul(way(0,0,r2 - 1,c2),way(r2,c2,N,M - 1)));
  107. }
  108. }
  109. c1 = min(i - 1,M) - v[i - 1] + 1,r1 = i - 1 - c1;
  110. c2 = min(i,M) - v[i] + 1,r2 = i - c2;
  111. if(v[i - 1]) {
  112. if(c2 > c1) {
  113. valv = inc(valv, MOD - mul(way(0,0,r1,c1),way(r1 + 1,c1,N - 1,M)));
  114. }
  115. else {
  116. if(c2 >= 1) valv = inc(valv,mul(way(0,0,r2,c2 - 1),way(r2,c2,N - 1,M)));
  117. }
  118. }
  119. }
  120. int ans = 0;
  121. for(int i = 0 ; i < N + M ; ++i) {
  122. ans = inc(ans,mul(f[i],inv[N + M - i]));
  123. }
  124. ans = mul(ans,fpow(C(N + M,N),MOD - 2));
  125. out(ans);enter;
  126. }
  127. int main() {
  128. #ifdef ivorysi
  129. freopen("f1.in","r",stdin);
  130. #endif
  131. Solve();
  132. }

【AtCoder】AGC019的更多相关文章

  1. 【AtCoder】ARC092 D - Two Sequences

    [题目]AtCoder Regular Contest 092 D - Two Sequences [题意]给定n个数的数组A和数组B,求所有A[i]+B[j]的异或和(1<=i,j<=n ...

  2. 【Atcoder】CODE FESTIVAL 2017 qual A D - Four Coloring

    [题意]给定h,w,d,要求构造矩阵h*w满足任意两个曼哈顿距离为d的点都不同色,染四色. [算法]结论+矩阵变换 [题解] 曼哈顿距离是一个立着的正方形,不方便处理.d=|xi-xj|+|yi-yj ...

  3. 【AtCoder】ARC 081 E - Don't Be a Subsequence

    [题意]给定长度为n(<=2*10^5)的字符串,求最短的字典序最小的非子序列字符串. http://arc081.contest.atcoder.jp/tasks/arc081_c [算法]字 ...

  4. 【AtCoder】AGC022 F - Leftmost Ball 计数DP

    [题目]F - Leftmost Ball [题意]给定n种颜色的球各k个,每次以任意顺序排列所有球并将每种颜色最左端的球染成颜色0,求有多少种不同的颜色排列.n,k<=2000. [算法]计数 ...

  5. 【AtCoder】AGC005 F - Many Easy Problems 排列组合+NTT

    [题目]F - Many Easy Problems [题意]给定n个点的树,定义S为大小为k的点集,则f(S)为最小的包含点集S的连通块大小,求k=1~n时的所有点集f(S)的和取模92484403 ...

  6. 【AtCoder】ARC067 F - Yakiniku Restaurants 单调栈+矩阵差分

    [题目]F - Yakiniku Restaurants [题意]给定n和m,有n个饭店和m张票,给出Ai表示从饭店i到i+1的距离,给出矩阵B(i,j)表示在第i家饭店使用票j的收益,求任选起点和终 ...

  7. 【AtCoder】ARC095 E - Symmetric Grid 模拟

    [题目]E - Symmetric Grid [题意]给定n*m的小写字母矩阵,求是否能通过若干行互换和列互换使得矩阵中心对称.n,m<=12. [算法]模拟 [题解]首先行列操作独立,如果已确 ...

  8. 【Atcoder】AGC022 C - Remainder Game 搜索

    [题目]C - Remainder Game [题意]给定n个数字的序列A,每次可以选择一个数字k并选择一些数字对k取模,花费2^k的代价.要求最终变成序列B,求最小代价或无解.n<=50,0& ...

  9. 【Atcoder】AGC 020 B - Ice Rink Game 递推

    [题意]n个人进行游戏,每轮只保留最大的a[i]倍数的人,最后一轮过后剩余2人,求最小和最大的n,或-1.n<=10^5. [算法]递推||二分 [题解]令L(i),R(i)表示第i轮过后的最小 ...

随机推荐

  1. 简述var、let、const三者的区别

    前二者为定义变量,const一般用来定义常量. 1.var声明变量可以重复声明,而let不可以重复声明 var name = 'xiaohuang'; var name = 'xiaolan'; co ...

  2. 2 Player and N Coin

    class Solution { public void printChoices(int[] A, int[][] C) { System.out.println("硬币列表如下:&quo ...

  3. 多文档界面QMdiArea

    当使用多文档界面功能时,我们是将QMdiArea作为主窗口的中央部件,然后在这个中央部件中,我们可以同时打开很多个子窗口QMdiSubWindow 样式: import sys from PyQt5. ...

  4. UE4的AI学习(2)——官方案例实例分析

    官方给出的AI实例是实现一个跟随着玩家跑的AI,当玩家没有在AI视野里时,它会继续跑到最后看到玩家的地点,等待几秒后如果仍然看不到玩家,则跑回初始地点.官方的案例已经讲得比较详细,对于一些具体的函数调 ...

  5. Navicat Premium连接各种数据库

    版本信息 Navicat Premium 是一套数据库开发工具,让你从单一应用程序中同时连接 MySQL.MariaDB.SQL Server.Oracle.PostgreSQL 和 SQLite 数 ...

  6. Android判断当前是否在主线程

    Android开发中, 有时需要判断当前线程到底是主线程, 还是子线程, 例如: 我们在自定义View时, 想要让View重绘, 需要先判断当前线程到底是不是主线程, 然后根据判断结果来决定到底是调用 ...

  7. ajax大并发问题

    今天在对项目做性能分析时发现,js代码中同时发出的多个异步请求耗时很长,查看服务器处理 时间发现,每个请求的响应都在毫秒级,但是页面请求的响应时间却在1秒左右,百思不得其解,后来仔细测试发现,这个并发 ...

  8. SpringBoot2.x使用Dev-tool热部署

    SpringBoot2.x使用Dev-tool热部署 为什么使用热部署? 当修改某些文件内容如配置文件时,我们需要重新启动服务器,比较麻烦,需要一个工具来进行检测是否修改.热加载可以检测到修改的部分, ...

  9. FPN 学习笔记

    通常,利用网络对物体进行检测时,浅层网络分辨率高,学到的是图片的细节特征,深层网络,分辨率低,学到的更多的是语义特征. 1).通常的CNN使用如下图中显示的网络,使用最后一层特征图进行预测 例如VGG ...

  10. Python中的__init__()和__call__()函数

    Python中的__init__()和__call__()函数 在Python的class中有一些函数往往具有特殊的意义.__init__()和__call__()就是class很有用的两类特殊的函数 ...