传送门

写了四个题就跑去打球了。第五题应该能肝出来的。

A - Airplane

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. inline int read() {
  5. int x = , f = ; char ch = getchar();
  6. while (ch < '' || ch > '') { if (ch == '-') f = -; ch = getchar(); }
  7. while (ch >= '' && ch <= '') { x = x * + ch - ; ch = getchar(); }
  8. return x * f;
  9. }
  10.  
  11. int main() {
  12. int a = read(), b = read(), c = read();
  13. int ans = 1e9;
  14. ans = min(ans, a + b);
  15. ans = min(b + c, ans);
  16. ans = min(ans, c + a);
  17. cout << ans << '\n';
  18. return ;
  19. }

B - Balance

看错题意了。。改的时候就直接暴力了一发。。

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. inline int read() {
  5. int x = , f = ; char ch = getchar();
  6. while (ch < '' || ch > '') { if (ch == '-') f = -; ch = getchar(); }
  7. while (ch >= '' && ch <= '') { x = x * + ch - ; ch = getchar(); }
  8. return x * f;
  9. }
  10.  
  11. const int N = ;
  12. int a[N], sum[N];
  13.  
  14. int main() {
  15. int n = read();
  16. for (int i = ; i <= n; i++) a[i] = read();
  17. for (int i = ; i <= n; i++) {
  18. sum[i] = sum[i - ] + a[i];
  19. }
  20. int ans = 1e9;
  21. for (int T = ; T < n; T++) {
  22. int sum0 = ;
  23. for (int i = ; i <= n; i++) {
  24. if (i <= T) sum0 += a[i];
  25. else break;
  26. }
  27. ans = min(ans, abs(sum[n] - sum0 - sum0));
  28. // printf("%d\n", ans);
  29. }
  30. printf("%d\n", ans);
  31. return ;
  32. }

C - Typical Stairs

题意:走台阶,一次走一至两个台阶,有些台阶是坏的,问走到第$n$个台阶的方案数

思路:就是普通的递推,坏的台阶$f[i]$设为0

  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4.  
  5. inline int read() {
  6. int x = , f = ; char ch = getchar();
  7. while (ch < '' || ch > '') { if (ch == '-') f = -; ch = getchar(); }
  8. while (ch >= '' && ch <= '') { x = x * + ch - ; ch = getchar(); }
  9. return x * f;
  10. }
  11.  
  12. const int N = 1e5 + ;
  13. const ll mod = 1e9 + ;
  14. bool vis[N];
  15. ll f[N];
  16.  
  17. int main() {
  18. int n = read(), m = read();
  19. while (m--) {
  20. int x = read();
  21. vis[x] = ;
  22. }
  23. f[] = ;
  24. if (!vis[]) f[] = ;
  25. for (int i = ; i <= n; i++) {
  26. if (vis[i]) continue;
  27. f[i] = (f[i - ] + f[i - ]) % mod;
  28. }
  29. printf("%lld\n", f[n]);
  30. return ;
  31. }

D - Lamp

题意:一个网格,有些地方是墙,问在哪个没有墙的地方放个灯,灯能照射的范围最远,灯能往上下左右延伸

思路:刚开始傻逼傻逼的对每个点往四个方向延伸,然后就获得了一个TLE。从左上对每个点统计从它的左方和上方分别能走多远,从右下对每个点统计从它的右方和下方分别能走多远

然后再对每一个点求一边四个方向的和的最大值

  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. inline int read() {
  5. int x = , f = ; char ch = getchar();
  6. while (ch < '' || ch > '') { if (ch == '-') f = -; ch = getchar(); }
  7. while (ch >= '' && ch <= '') { x = x * + ch - ; ch = getchar(); }
  8. return x * f;
  9. }
  10.  
  11. const int N = ;
  12. char s[N][N];
  13. int dp[N][N][];
  14.  
  15. int main() {
  16. int n = read(), m = read();
  17. for (int i = ; i < n; i++) {
  18. scanf("%s", s[i]);
  19. }
  20. int ans = ;
  21. for (int i = ; i < n; i++) {
  22. for (int j = ; j < m; j++) {
  23. if (s[i][j] == '.') {
  24. dp[i][j][] = dp[i][j][] = ;
  25. if (j > && dp[i][j - ][] > ) dp[i][j][] = dp[i][j - ][] + ;
  26. if (i > && dp[i - ][j][] > ) dp[i][j][] = dp[i - ][j][] + ;
  27. }
  28. }
  29. }
  30. for (int i = n - ; i >= ; i--) {
  31. for (int j = m - ; j >= ; j--) {
  32. if (s[i][j] == '.') {
  33. dp[i][j][] = dp[i][j][] = ;
  34. if (j < m - && dp[i][j + ][] > ) dp[i][j][] = dp[i][j + ][] + ;
  35. if (i < n - && dp[i + ][j][] > ) dp[i][j][] = dp[i + ][j][] + ;
  36. }
  37. }
  38. }
  39. for (int i = ; i < n; i++) {
  40. for (int j = ; j < m; j++) {
  41. if (s[i][j] == '#') continue;
  42. int temp = ;
  43. for (int cnt = ; cnt < ; cnt++) temp += dp[i][j][cnt];
  44. ans = max(ans, temp - );
  45. }
  46. }
  47. printf("%d\n", ans);
  48. return ;
  49. }

E - Sum Equals Xor

题意:给一个二进制数$L$,问有多少对$\left(a,b\right)$满足:$a+b \leq L$   $a+b = a \oplus b$

思路:为啥别人看到都直接莽DP啊,为啥我看到就推公式啊。因为第二个条件,对于每一位 $a$和$b$只能为$\left(0,0\right)$ $\left(1,0\right)$ $\left(0, 1\right)$ 三种情况

所以如果给出的$L$是全1,那么答案就是$3^{len}$,但是由于第一个条件存在,那么对于每一位为0的,不能出现 1.比他高位的1的位置出现 $\left(1,0\right)$ $\left(0, 1\right)$ 2.这个位置出现$\left(1,0\right)$ $\left(0, 1\right)$ 那么就用一个系数$c$来保存1位置,每到一个1位置, $c$乘2,每到一个0位置,答案减去 $c \times 3 ^{x}$ $x$是这个位置往后的数的长度 就是前面1位置出现了一个为0一个为1 这个0位置出现一个0一个为1 $a + b$就会大于$L$ 那么后面的随机组合的情况就是多出来了 所以减去就完了。

代码里面还有一个是DP的,我是拿来对拍的...

  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4.  
  5. const ll mod = 1e9 + ;
  6.  
  7. ll qp(ll a, ll b) {
  8. ll res = ;
  9. while (b) {
  10. if (b & ) res = res * a % mod;
  11. a = a * a % mod;
  12. b >>= ;
  13. }
  14. return res;
  15. }
  16.  
  17. const int N = 1e5 + ;
  18. char s[N];
  19. ll dp[N];
  20. ll bit[N];
  21.  
  22. int main() {
  23. scanf("%s", s);
  24. int len = strlen(s);
  25. ll ans = qp(, len);
  26. bit[] = ;
  27. for (int i = ; i <= len; i++) bit[i] = bit[i - ] * % mod;
  28. if (s[] == '') ans = (ans - * qp(, len - )) % mod;
  29. ll temp = ;
  30. for (int i = ; i < len; i++) {
  31. if (s[i] == '') ans = (ans - temp * bit[len - i - ] % mod + mod) % mod;
  32. else temp = temp * % mod;
  33. }
  34. // dp[0] = 1;
  35. // reverse(s, s + len);
  36. // for (int i = 0; i < len; i++) {
  37. // if (s[i] == '1') dp[i + 1] = (2 * dp[i] + bit[i]) % mod;
  38. // else dp[i + 1] = dp[i];
  39. // }
  40. printf("%lld\n", ans);
  41. return ;
  42. }

F - Takahashi's Basics in Education and Learning

题意:给一个等差数列的首项和公差和项数,把这$L$项给拼起来,问最后这个大数模$M$的答案是多少

思路:完全没明白咋写...看了别人的代码看半天才懂...

这个大数的组成就是$a_{0}\times 10^{b_{0}\cdot }+a_{1}\times 10^{b_{1}}+\ldots +a_{L - 1}\times 10^{b_{L - 1}}$

答案把这$L$项按他们的长度分类 然后对于每一个构造一个矩阵

$\begin{pmatrix} bit & 1 & 0 \\ 0 & 1 & d \\ 0 & 0 & 1 \end{pmatrix}$

答案矩阵为$\begin{pmatrix} ans \\ a_{st} \\ 1 \end{pmatrix}$

找到$a_{st}$二分就OK了

学习了。

  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4.  
  5. inline ll read() {
  6. ll x = , f = ; char ch = getchar();
  7. while (ch < '' || ch > '') { if (ch == '-') f = -; ch = getchar(); }
  8. while (ch >= '' && ch <= '') { x = x * + ch - ; ch = getchar(); }
  9. return x * f;
  10. }
  11.  
  12. ll mod;
  13.  
  14. struct M { ll a[][]; };
  15. M operator * (const M &a, const M &b) {
  16. M c;
  17. for (int i = ; i < ; i++) {
  18. for (int j = ; j < ; j++) {
  19. c.a[i][j] = ;
  20. for (int k = ; k < ; k++) {
  21. c.a[i][j] = (c.a[i][j] + a.a[i][k] * b.a[k][j] % mod) % mod;
  22. }
  23. }
  24. }
  25. return c;
  26. }
  27.  
  28. M qp(M a, ll b) {
  29. M c;
  30. for (int i = ; i < ; i++) for (int j = ; j < ; j++) c.a[i][j] = i == j;
  31. while (b) {
  32. if (b & ) c = c * a;
  33. a = a * a;
  34. b >>= ;
  35. }
  36. return c;
  37. }
  38.  
  39. int main() {
  40. ll n = read(), a0 = read(), d = read(); mod = read();
  41. ll bit = , ans = ;
  42. ll st = ;
  43. for (int i = ; i <= ; i++) {
  44. ll l = st, r = n, p = -;
  45. while (l + < r) {
  46. ll mid = l + r >> ;
  47. if (mid * d + a0 < bit) l = mid , p = mid;
  48. else r = mid;
  49. }
  50. if (l * d + a0 < bit) p = l;
  51. if (p != -) {
  52. M a;
  53. a.a[][] = bit % mod; a.a[][] = a.a[][] = a.a[][] = 1LL;
  54. a.a[][] = a.a[][] = a.a[][] = a.a[][] = 0LL;
  55. a.a[][] = d % mod;
  56. a = qp(a, p - st + );
  57. ll ast = a0 % mod + d % mod * st % mod; ast %= mod;
  58. ans = (ans * a.a[][] % mod + ast * a.a[][] % mod + a.a[][] % mod) % mod;
  59. st = p + ;
  60. }
  61. if (st >= n) break;
  62. bit *= ;
  63. }
  64. printf("%lld\n", ans);
  65. return ;
  66. }

AtCoder Beginner Contest 129 解题报告的更多相关文章

  1. AtCoder Beginner Contest 122 解题报告

    手速选手成功混进rated only里面的前30名,但是总排名就到110+了... A - Double Helix #include <bits/stdc++.h> #define ll ...

  2. AtCoder Beginner Contest 146解题报告

    题目地址 https://atcoder.jp/contests/abc146/tasks 感觉没有什么有意思的题... 题解 A #include <bits/stdc++.h> usi ...

  3. Atcoder Beginner Contest 124 解题报告

    心态爆炸.本来能全做出来的.但是由于双开了Comet oj一个比赛,写了ABC就去搞那个的B题 还被搞死了. 回来写了一会D就过了.可惜比赛已经结束了.真的是作死. A - Buttons #incl ...

  4. AtCoder Beginner Contest 118 解题报告

    A - B +/- A #include <bits/stdc++.h> int main() { int a, b; std::cin >> a >> b; b ...

  5. AtCoder Beginner Contest 120 解题报告

    为啥最近都没有arc啊... A - Favorite Sound #include <algorithm> #include <iostream> #include < ...

  6. AtCoder Beginner Contest 117 解题报告

    果然abc都是手速场. 倒序开的qwq. D题因为忘记1e12二进制几位上界爆了一发. A - Entrance Examination 就是除一下就行了... 看样例猜题意系列. #include& ...

  7. AtCoder Beginner Contest 132 解题报告

    前四题都好水.后面两道题好难. C Divide the Problems #include <cstdio> #include <algorithm> using names ...

  8. AtCoder Beginner Contest 127 解题报告

    传送门 非常遗憾.当天晚上错过这一场.不过感觉也会掉分的吧.后面两题偏结论题,打了的话应该想不出来. A - Ferris Wheel #include <bits/stdc++.h> u ...

  9. AtCoder Beginner Contest 126 解题报告

    突然6道题.有点慌.比赛写了五个.罚时爆炸.最后一个时间不太够+没敢写就放弃了. 两道题奇奇怪怪的WJ和20/20.今天的评测机是怎么了. A Changing a Character #includ ...

随机推荐

  1. Versioning information could not be retrieved from the NuGet package repository. Please try again later.

    Versioning information could not be retrieved from the NuGet package repository. Please try again la ...

  2. 全能中间件v19.5.7 正式版发布

    v19.5.7 更新=========================1.新增 支持更多微信公众号API.2.优化 AccessToken 刷新机制.3.修复 微信公众号“消息加解密方式”为“安全模式 ...

  3. LeetCode 1259. Handshakes That Don't Cross - Java - DP

    题目链接:https://leetcode-cn.com/problems/handshakes-that-dont-cross/ You are given an even number of pe ...

  4. XXE任意文件读取(当xml解析内容有输出时)

    利用XXE漏洞读取文件 参考:https://www.jianshu.com/p/4fc721398e97 首先找到登录源码如下: 由题目可以利用XXE漏洞读取文件 先登录用Burp Suite抓包: ...

  5. 在local模式下的spark程序打包到集群上运行

    一.前期准备 前期的环境准备,在Linux系统下要有Hadoop系统,spark伪分布式或者分布式,具体的教程可以查阅我的这两篇博客: Hadoop2.0伪分布式平台环境搭建 Spark2.4.0伪分 ...

  6. nginx+lua+storm的热点缓存的流量分发策略自动降级

    1.在storm中,实时的计算出瞬间出现的热点. 某个storm task,上面算出了1万个商品的访问次数,LRUMap 频率高一些,每隔5秒,去遍历一次LRUMap,将其中的访问次数进行排序,统计出 ...

  7. IntelliJ IDEA 换背景免费酷炫的插件(转)

    一.插件的安装 打开setting文件选择Plugins选项 Ctrl + Alt + S File -> Setting 分别是安装JetBrains插件,第三方插件,本地已下载的插件包. 二 ...

  8. js调用浏览器下载

    $scope.Download = function (url) { var save_link = document.createElementNS("http://www.w3.org/ ...

  9. tf.nn.softmax_cross_entropy_with_logits()函数的使用方法

    import tensorflow as tf labels = [[0.2,0.3,0.5], [0.1,0.6,0.3]]logits = [[2,0.5,1], [0.1,1,3]] a=tf. ...

  10. 2019 4399java面试笔试题 (含面试题解析)

    本人3年开发经验.18年年底开始跑路找工作,在互联网寒冬下成功拿到阿里巴巴.今日头条.4399等公司offer,岗位是Java后端开发,最终选择去了4399. 面试了很多家公司,感觉大部分公司考察的点 ...