ABC340

C

黑板上给一个数N,一直不停重复到黑板上的数组里面只剩下1:
擦去每个大于1的数n
加入 ⌊ n 2 ⌋ 和 ⌈ n 2 ⌉ \lfloor \frac n 2 \rfloor和 \lceil \frac n 2 \rceil 2n2n
每擦一个数n计入分数n
求最后的总分数


用map记录一下每个n的总得分

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <algorithm>using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;ll n;
map<ll, ll> h;ll get(ll x) {if (h.count(x)) return h[x];if (x == 1) return 0;if (x % 2 == 0) {return h[x] = get(x / 2) * 2 + x;}else {return h[x] = get(x / 2) + get(x / 2 + 1) + x;}
}int main(){//freopen("in.txt", "r", stdin);cin >> n;ll ans = get(n);printf("%lld\n", ans);return 0;
}

D

1…N的一个数组,一开始在格子1
对于格子i有两个操作,一个花费 A i A_i Ai到i+1,第二个花费 B i B_i Bi到d
求最后到N的最小花费


优先队列

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <algorithm>using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;int n;
int a[200020], b[200020], x[200020];
ll f[200020];
vector<pair<int, ll>> g[200020];struct Node {ll w;int u;bool operator < (const Node& rhs) const {return w > rhs.w;}
};int main(){//freopen("in.txt", "r", stdin);cin >> n;memset(f, 0x33, sizeof(f));f[1] = 0;for (int i = 1; i < n; ++i) {cin >> a[i] >> b[i] >> x[i];g[i].push_back({ x[i], b[i] });g[i].push_back({ i + 1, a[i] });}priority_queue<Node> qu;qu.push({ 0, 1 });while (qu.size()) {auto [w, u] = qu.top();qu.pop();if (u == n) {break;}for (auto [v, tw]: g[u]) {if (w + tw < f[v]) {f[v] = w + tw;qu.push({ f[v], v });}}}printf("%lld\n", f[n]);return 0;
}

E

围成一圈的n个格子,每个格子里都放着 A i A_i Ai个球
m个操作,格子 M i M_i Mi
将格子里面的球拿出来,按顺序依次放到所有格子里面,每次放一个
求最后每个格子里有几个球


对单点更新(清零)–就是区间更新,单点查询,裸的线段树。BIT+差分也可。

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <algorithm>using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;int n, m;
const int N = 200020;
ll a[N];
#define lu (u * 2)
#define ru (u * 2 + 1)struct SegTree {struct Node {int l, r;ll val, add;}tr[N << 2];void push_down(int u) {if (tr[u].add) {tr[lu].add += tr[u].add;tr[ru].add += tr[u].add;tr[u].add = 0;}}public:void build(int l, int r, int u) {tr[u].l = l, tr[u].r = r, tr[u].add = 0;if (l == r) {tr[u].val = a[l];return;}int mi = (l + r) / 2;build(l, mi, lu);build(mi + 1, r, ru);}void update(int l, int r, int u, ll v) {if (l <= tr[u].l && tr[u].r <= r) {tr[u].add += v;return;}push_down(u);int mi = (tr[u].l + tr[u].r) / 2;if (mi >= l)update(l, r, lu, v);if (mi < r) update(l, r, ru, v);}ll query(int p, int u) {if (tr[u].l == tr[u].r) {return tr[u].val + tr[u].add;}push_down(u);int mi = (tr[u].l + tr[u].r) / 2;if (p <= mi) return query(p, lu);else return query(p, ru);}
} seg;int main(){//freopen("in.txt", "r", stdin);cin >> n >> m;for (int i = 1; i <= n; ++i) cin >> a[i];seg.build(1, n, 1);for (int i = 0; i < m; ++i) {int t;cin >> t;t++;ll c = seg.query(t, 1);seg.update(t, t, 1, -c);seg.update(1, n, 1, c / n);ll r = c % n;if (r) {if (t + r <= n) {seg.update(t + 1, t + r, 1, 1);}else {if (t < n) {seg.update(t + 1, n, 1, 1);}seg.update(1, r - (n - t), 1, 1);}}}for (int i = 1; i <= n; ++i) {ll c = seg.query(i, 1);printf("%lld ", c);}printf("\n");return 0;
}

F

给(0,0)点和(X,Y)点,求任意(A,B)点使得三角形面积为1


三角形面积公式
x 1 y 2 + x 2 y 3 + x 3 y 1 − x 1 y 3 − x 2 y 1 − x 3 y 2 = S x_1y_2+x_2y_3+x_3y_1-x_1y_3-x_2y_1-x_3y_2=S x1y2+x2y3+x3y1x1y3x2y1x3y2=S
化简为 a y − b x = 2 ay-bx=2 aybx=2
扩展欧几里得做就好了

#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <algorithm>using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;ll X, Y;
// ax - by = 2ll gcd(ll a, ll b) {if (a < b) swap(a, b);if (b == 0) return a;return gcd(b, a % b);
}ll exgcd(ll a, ll b, ll& x, ll& y) {if (b == 0) {x = 1, y = 0;return a;}ll x0, y0;ll d = exgcd(b, a % b, x0, y0);// b x0 + a%b y0 = d// b x0 + (a - (a / b)b) y0 = d// b x0 + a y0 - (a / b) b y0 = d// b(x0 - (a/b) y0) + a y0 = d// by + ax = d// y = x0 - (a/b)y0, x = y0y = x0 - (a / b) * y0, x = y0;return d;
}int main(){//freopen("in.txt", "r", stdin);cin >> X >> Y;ll lx = abs(X), ly = abs(Y);ll d = gcd(lx, ly);if (d > 2) {printf("-1\n");return 0;}ll x, y;exgcd(X, Y, y, x);y = -y;if (d == 1) {printf("%lld %lld\n", x * 2, y * 2);}else {printf("%lld %lld\n", x, y);}return 0;
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.xdnf.cn/news/1559865.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

基于xml配置文件的Spring事务

在项目中对事务属性通常传播属性&#xff0c;回滚属性&#xff0c;隔离级别&#xff0c;超时属性都取默认值&#xff0c;只有只读属性会如下的配置&#xff1a; 什么意思&#xff1a;Service层你的类里的方法&#xff0c;以get&#xff0c;find&#xff0c;select等开头的方法是…

shell注意点

变量命名&#xff1a; 注意&#xff0c;变量名和等号之间不能有空格&#xff0c;定义变量时&#xff0c;变量名不加美元符号$&#xff0c;这可能和你熟悉的所有编程语言都不一样。同时&#xff0c;变量名的命名须遵循如下规则&#xff1a; 只包含字母、数字和下划线&#xff…

【text2sql】ReFSQL检索生成框架

论文标题为《ReFSQL: A Retrieval-Augmentation Framework for Text-to-SQL Generation》&#xff0c;发表在 EMNLP 2023 上。ReFSQL框架通过结构增强检索器来获取与当前问题语义和模式结构相似的样本&#xff0c;然后通过对比学习机制来引导模型学习到这些样本的特定知识&…

10款超实用的Sketch插件合集,别错过!

在 UI 界面设计领域&#xff0c;Sketch 以其高效、轻便的优势获得了不少设计团队的青睐&#xff0c;帮助全球设计师创造了许多妙不可言的作品。在使用 Sketch 的过程中&#xff0c;使用一些 辅助用的 Sketch 插件&#xff0c;可以让我们更加高效地完成设计任务。本文将将揭秘大…

jenkins中的allure和email问题梳理

一、allure相关 1、我安装了jenkins之后需要再安装allure吗&#xff1f;在jenkins插件中心直接安装allure 1.Allure Jenkins Plugin 只是一个集成插件&#xff0c;它要求你在 Jenkins 服务器上安装 Allure 命令行工具&#xff08;Allure Commandline&#xff09;来实际生成报…

Spring Boot教学资源库:从入门到精通

1绪 论 1.1研究背景 目前&#xff0c;在网络大环境下&#xff0c;越来越多高校开始实行网络教学&#xff0c;利用网络教学方式有利于学生更好的学习。 网络教学是指以计算机及网络为基础&#xff0c;来实现教学资源的上传、存储、传播和共享的教学手段。它是一种教学活动&#…

伪随机调制

伪随机调制是一种利用伪随机序列来调制信号的技术&#xff0c;广泛应用于现代通信系统中。其主要目的在于增强信号的抗干扰能力和隐蔽性&#xff0c;同时提升数据传输的安全性。以下是关于伪随机调制的详细介绍&#xff0c;包括原理、数学表达以及应用。 一、原理 1. 伪随机序…

ITSS-IT服务工程师和ITSS-IT服务经理的区别

培训目的差异&#xff1a;ITSS 服务项目经理的培训旨在为应对 IT 服务行业一线管理人员短缺的问题提供有力支持&#xff1b;而 ITSS 服务工程师的培训则致力于向 IT 服务业输送初级人才&#xff0c;协助企业将一部分内部成本转移至社会。 培训方向区分&#xff1a;ITSS 服务经理…

基于Springboot+Vue的智能推荐旅游平台 (含源码数据库)

1.开发环境 开发系统:Windows10/11 架构模式:MVC/前后端分离 JDK版本: Java JDK1.8 开发工具:IDEA 数据库版本: mysql5.7或8.0 数据库可视化工具: navicat 服务器: SpringBoot自带 apache tomcat 主要技术: Java,Springboot,mybatis,mysql,vue 2.视频演示地址 3.功能 系统中…

【Python】Conda离线执行命令

以下链接证明了想要离线使用conda命令的方法 启用离线模式 — Anaconda documentation 基本上大部分的命令都会提供网络选项 例如creat命令 conda create — conda 24.7.1 文档 - Conda 文档

英国商科毕业论文选题常见错误与解决思路

每到毕业季&#xff0c;英国商科毕业论文的选题和确定题目往往是留学生头痛的一大难题。如何有效确定英国毕业论文题目&#xff1f;如何避免题目中出现一些错误导致研究不能进行&#xff1f;在这篇文章中&#xff0c;翰思教育小编将逐一分析各种可能的问题以及如何避免这些问题…

12.JVM类加载机制

一、什么是JVM JVM是一种计算设备规范&#xff0c;虚构出的一个计算机&#xff0c;具有跨平台的特性&#xff1b; 包含类加载器、程序计数器、执行引擎、堆栈、方法区&#xff08;元数据区&#xff09;、本地方法栈 二、类加载全过程 加载过程如下&#xff1a;加载 --》验证…

Spring Cloud Netflix Hystrix 熔断器讲解和案例示范

在分布式微服务架构中&#xff0c;每个服务之间相互依赖&#xff0c;当某个服务出现故障或延迟时&#xff0c;如果没有有效的故障隔离机制&#xff0c;可能导致整个系统雪崩式的失败。Netflix Hystrix 作为一种熔断器模式&#xff0c;旨在通过隔离服务之间的调用&#xff0c;提…

bladex漏洞思路总结

Springblade框架介绍&#xff1a; SpringBlade是一个基于Spring Boot和Spring Cloud的微服务架构框架&#xff0c;它是由商业级项目升级优化而来的综合型项目。 0x1 前言 最近跟一些大佬学习了blade的漏洞&#xff0c;所以自己总结了一下&#xff0c;在渗透测试过程中&#x…

数据排列组合实现

示例 将以下几组数据 &#xff08;“01”, “02”&#xff09;&#xff0c;&#xff08;“A1”, “A2”, “A3”&#xff09;&#xff0c;&#xff08;“B1”, “B2”&#xff09;&#xff0c;&#xff08;“D1”, “D3”&#xff09;排列组合成&#xff0c;如&#xff1a;01:…

如何利用phpstudy创建mysql数据库

phpStudy诞生于2007年&#xff0c;是一款老牌知名的PHP开发集成环境工具&#xff0c;产品历经多次迭代升级&#xff0c;目前有phpStudy经典版、phpStudy V8&#xff08;2019版&#xff09;等等&#xff0c;利用phpstudy可以快速搭建一个mysql环境&#xff0c;接下来我们就开始吧…

【纯前端实现xlsx的解析并处理成table需要的格式】

概要 xlsx纯前端导入并解析成json 整体架构流程 xlsx导入并解析成json&#xff0c;并与table中的数据进行对比&#xff0c;根据唯一标识更新对应数据项 技术名词解释 vue2xlsx 技术细节 首先下载xlsx依赖 npm install xlsx --save然后在需要导入xlsx的地方 这里主要用in…

【金九银十】笔试通关 + 小学生都能学会的堆排序

算法原理 堆排序是一种基于比较的排序算法&#xff0c;它利用了数据结构中的堆&#xff08;Heap&#xff09;。堆是一种特殊的完全二叉树&#xff0c;分为最大堆&#xff08;Max-Heap&#xff09;和最小堆&#xff08;Min-Heap&#xff09;。在最大堆中&#xff0c;每个父节点…

代码开发效率提升秘籍

&#x1f381;&#x1f449;点击进入文心快码 Baidu Comate 官网&#xff0c;体验智能编码之旅&#xff0c;还有超多福利&#xff01;&#x1f381; 理解代码 大部分的开发场景&#xff0c;不是自己从头开始写码&#xff0c;而是基于历史代码进行增量开发。历史代码往往经历多…

探寻vcruntime140.dll的奥秘:解决vcruntime140.dll相关程序运行故障的指南

今天这篇文章就来和大家聊聊关于丢失vcruntime140.dll文件的问题&#xff0c;分档你的电脑中随时了vcruntime140.dll文件时有什么办法可以将丢失vcruntime140.dll进行找回呢&#xff1f;有什么办法可以将丢失的vcruntime140.dll修复&#xff1f;vcruntime140.dll丢失导致电脑不…