直接从 D 开始了。

D

可可爱爱的二分捏。

check 就按照题目里写的就行了。

然后 \(l\) 的初值要注意一下,就是 \(\max^{i \le n}_{i=1}a_i\)。

代码:

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 2e5 + 10;
int n,m;
int a[maxn];
int l,r = 1e18;
bool check(int x)
{
int now = a[1],cnt = 1;
for(int i = 2;i <= n;i++)
{
if(now + a[i] + 1 > x)
{
cnt++;
now = a[i];
}
else
{
now += a[i] + 1;
}
}
return cnt <= m;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin >> n >> m;
for(int i = 1;i <= n;i++)
{
cin >> a[i];
l = max(l,a[i]);
}
int ans = 0;
while(l <= r)
{
int mid = l + r >> 1;
if(check(mid))
{
r = mid - 1;
ans = mid;
}
else
{
l = mid + 1;
}
}
cout << ans;
return 0;
}

E

看到 \(q_i \le 10^9\),不可以暴力直接做。

由于 \(1 \le P_i \le 8\),于是我们想到每 \(LCM(1,2 \cdots ,8) = 840\),所以只用记录 \(q_i\) 模 \(840\) 的结果就行了。

预处理前 \(840\) 秒数,然后计算答案即可。

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 2e5 + 10;
int n,m,k,q,a[maxn],b[maxn],res[maxn];
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin >> n >> m >> k;
for(int i = 1;i < n;i++)
{
cin >> a[i] >> b[i];
}
for(int i = 0;i < 840;i++)
{
int T = i + m;
res[i] = m;
for(int j = 1;j < n;j++)
{
while(T % a[j] != 0)
{
T++;
res[i]++;
}
T += b[j];
res[i] += b[j];
}
res[i] += k;
}
cin >> q;
while(q--)
{
int x;
cin >> x;
cout << x + res[x % 840] << '\n';
}
return 0;
}

ABC319题解的更多相关文章

  1. 2016 华南师大ACM校赛 SCNUCPC 非官方题解

    我要举报本次校赛出题人的消极出题!!! 官方题解请戳:http://3.scnuacm2015.sinaapp.com/?p=89(其实就是一堆代码没有题解) A. 树链剖分数据结构板题 题目大意:我 ...

  2. noip2016十连测题解

    以下代码为了阅读方便,省去以下头文件: #include <iostream> #include <stdio.h> #include <math.h> #incl ...

  3. BZOJ-2561-最小生成树 题解(最小割)

    2561: 最小生成树(题解) Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 1628  Solved: 786 传送门:http://www.lyd ...

  4. Codeforces Round #353 (Div. 2) ABCDE 题解 python

    Problems     # Name     A Infinite Sequence standard input/output 1 s, 256 MB    x3509 B Restoring P ...

  5. 哈尔滨理工大学ACM全国邀请赛(网络同步赛)题解

    题目链接 提交连接:http://acm-software.hrbust.edu.cn/problemset.php?page=5 1470-1482 只做出来四道比较水的题目,还需要加强中等题的训练 ...

  6. 2016ACM青岛区域赛题解

    A.Relic Discovery_hdu5982 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Jav ...

  7. poj1399 hoj1037 Direct Visibility 题解 (宽搜)

    http://poj.org/problem?id=1399 http://acm.hit.edu.cn/hoj/problem/view?id=1037 题意: 在一个最多200*200的minec ...

  8. 网络流n题 题解

    学会了网络流,就经常闲的没事儿刷网络流--于是乎来一发题解. 1. COGS2093 花园的守护之神 题意:给定一个带权无向图,问至少删除多少条边才能使得s-t最短路的长度变长. 用Dijkstra或 ...

  9. CF100965C题解..

    求方程 \[ \begin{array}\\ \sum_{i=1}^n x_i & \equiv & a_1 \pmod{p} \\ \sum_{i=1}^n x_i^2 & ...

  10. JSOI2016R3 瞎BB题解

    题意请看absi大爷的blog http://absi2011.is-programmer.com/posts/200920.html http://absi2011.is-programmer.co ...

随机推荐

  1. 【笔记】Java相关大杂烩①

    [笔记]Java相关大杂烩 Java 程序的执行流程是? *.java 文件-->*.class 文件-->类装载器-->字节码校验器-->解释器-->操作系统平台 Ja ...

  2. Alibaba Cloud Linux 2 LTS 正式发布,提供更高性能和更多保障

    Alibaba Cloud Linux 2 LTS版本发布后,阿里云将会为该版本提供长达5年的软件维护.问题修复服务.从2019-03-27开始到2024-03-31结束.包括: 免费的服务和支持:A ...

  3. 使用Databricks进行零售业需求预测的应用实践

    ​简介:本文从零售业需求预测痛点.商店商品模型预测的实践演示,介绍Databricks如何助力零售商进行需求.库存预测,实现成本把控和营收增长. 作者:李锦桂 阿里云开源大数据平台开发工程师 本文从零 ...

  4. 如何使用Arthas提高日常开发效率?

    简介: 1. Arthas有什么功能,怎么用,请看:Arthas使用手册 2. Arthas命令比较复杂,一个帮助生成命令的IDEA插件:arthas idea plugin 使用文档 3. 基于Ar ...

  5. [FAQ] dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.64.dylib

    通过 ls -al /usr/local/opt 可以看到 icu4c 链接的不是 libicui18n.64.dylib. 一般是 node 版本问题会出现该提示,通过观察版本大小,决定是升级还是使 ...

  6. [FAQ] Truffle Deployer 合约传参问题: Invalid number of parameters for "undefined". Got 0 expected 1!

    在使用 `truffle migrate` 时,如果合约的构造函数需要传参,而部署脚本里没有传的时候,就会报这个错. 未传参时: const Migrations = artifacts.requir ...

  7. [PHP] 浅谈 Laravel Authorization 的 gates 与 policies

    首先要区分 Authentication 与 Authorization,认证和授权,粗细有别. 授权(Authorization) 有两种主要方式,Gates 和 Policies. Gates 和 ...

  8. SpringBoot使用JSch操作Linux

    推荐使用Hutool的Jsch工具包(它用的连接池的技术) 一.SSH远程连接服务器 SSH更多见:http://t.csdnimg.cn/PrsNv 推荐连接工具:FinalShell.Xshell ...

  9. Ollama开发指南

    安装必备工具 确保已安装以下软件的正确版本: CMake 3.24 或更高版本 Go 1.22 或更高版本 GCC 11.4.0 或更高版本 使用 Homebrew 安装这些工具(适用于macOS和L ...

  10. kube-proxy 流量流转方式

    简介 kube-proxy 是 Kubernetes 集群中负责服务发现和负载均衡的组件之一.它是一个网络代理,运行在每个节点上, 用于 service 资源的负载均衡.它有两种模式:iptables ...