当前位置: 首页 > news >正文

AcWing第 127 场周赛 - AcWing 5283. 牛棚入住+AcWing 5284. 构造矩阵 - 模拟+快速幂+数学

AcWing 5283. 牛棚入住

题目数据范围不大,直接暴力模拟即可
按照题目所说的意思即可。

#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
const int N = 1e5 + 10;
#define de(x) cout << x << " ";
#define sf(x) scanf("%d", &x);
#define Pu puts("");
#define ll long long
int n, m, ans;
int a, b, c;  // 空的小栏,空的大栏,半空的大栏
int main() {cin >> n >> a >> b;c = 0;ans = 0;int x;while (n--) {cin >> x;// 按照题意进行简单模拟if (x == 1) {if (a > 0) {a--;} else if (b > 0) {b--;c++;} else if (c > 0) {c--;} else {ans++;}} else {if (b > 0) {b--;} else {ans += 2;}}}cout << ans << endl;return 0;
}

AcWing 5284. 构造矩阵

题解参考思路
上面的题解讲的很好

在这里插入图片描述
AC代码如下:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sf(x) scanf("%d", &x);
#define de(x) cout << x << " ";
#define Pu puts("");
const int N = 1e5 + 9, mod = 1e9 + 7;
ll n, m, ans;  // 注意n和m数据范围是long long
int k;
ll qmi(ll x, ll y) {  // 快速幂ll res = 1;while (y) {if (y & 1)res = (ll)(res * x) % mod;x = (ll)(x * x) % mod;y >>= 1;}return res;
}
int main() {cin >> n >> m >> k;if ((n + m & 1) && k == -1)cout << 0 << endl;elsecout << qmi(qmi(2, n - 1), m - 1) << endl;return 0;
}
http://www.lryc.cn/news/212808.html

相关文章:

  • 2023-10-31 游戏开发-微信小游戏-文档记录
  • 2023NOIP A层联测21-异或
  • 分布式存储系统Ceph应用组件介绍
  • 【数据结构】数组和字符串(十一):字符串的定义与存储(顺序存储、链式存储及其C语言实现)
  • zk-Bench:SNARKs性能对比评估工具
  • 【Linux】NTP服务器配置、时间修改
  • 毕业设计基于SpringMVC+Mybatis+Bootstrap的电影院管理系统源码+数据库
  • vantUI(Tabbar标签页)浏览器返回上一页的失效问题
  • 【算法】Prim算法(求最小生成树)
  • go语言,yaml实现简单的workflow工作流
  • BaiduMallServcie
  • vue3+jsx+antd的插槽写法之一
  • Shell 学习之 if 命令
  • android 同步 服务器 时间
  • 10、电路综合-基于简化实频的宽带匹配电路设计方法
  • N-130基于springboot,vue校园社团管理系统
  • Syntax Error: TypeError: this.getOptions is not a function的解决(Vue)
  • 使用 kube-downscaler 降低Kubernetes集群成本
  • LeetCode热题100——哈希表
  • Kubeadm
  • 【Overload游戏引擎细节分析】PBR材质Shader---完结篇
  • C++设计模式_18_State 状态模式
  • 详解final, abstract, interface关键字
  • 统计特殊四元组
  • 腾讯云轻量应用服务器“镜像”怎么选择合适?
  • Ruby模块和程序组织
  • 14、SpringCloud -- WebSocket 实时通知用户
  • 智能井盖传感器推荐,万宾科技助力城市信息化建设
  • 3D模型格式转换工具HOOPS Exchange对工业级3D产品HOOPS的支持与应用
  • table 表体滚动, 表头、表尾固定