第八场

CodeForces - 1288A. Deadline

Example

input

3
1 1
4 5
5 11

output

YES
YES
NO

Note

In the first test case, Adilbek decides not to optimize the program at all, since \(d≤n\).

In the second test case, Adilbek can spend \(1\) day optimizing the program and it will run \(⌈\frac52⌉=3\) days. In total, he will spend \(4\) days and will fit in the limit.

In the third test case, it's impossible to fit in the limit. For example, if Adilbek will optimize the program \(2\) days, it'll still work \(⌈\frac{11}{2+1}⌉=4\) days.

题意:

\(Adilbek\) 有一个编程任务,总工期为 \(n\) 天,直接暴力完成需要 \(d\) 天。但他可以选择花 \(x\) 天进行优化,然后再花 \(⌈\frac{d}{x + 1}⌉\) 天运行。如果可以在工期内完成则输出 \(YES\) 不然输出 \(NO\)。

思路:

如果暴力完成天数小于工期则不需要去特地优化,不然的话需要进行优化但优化天数是不能超过 工期数(即 \(x < n\))。

详解看代码更好理解。

#include<bits/stdc++.h>
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long ll;
const int N = 1e5 + 100;
ll _, n, d, a[N], i, j;
void solve() {
cin >> n >> d;
if (d <= n) {
cout << "YES" << endl;
return;
}
for (int x = 1; x < d && x <= n; ++x) {
if ((x + ceil((float)d / (x + 1))) <= n) {//必须要先提高精度(float化)不然在除的时候会导致错误,如4/3 = 1.333 = 1发生错误
cout << "YES" << endl;
return;
}
}
cout << "NO" << endl;
} int main() {
//freopen("in.txt", "r", stdin);
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> _; while (_--) solve();
}

CodeForces - 1288B. Yet Another Meme Problem

input

3
1 11
4 2
191 31415926

output

1
0
1337

Note

There is only one suitable pair in the first test case: \(a=1, b=9 (1+9+1⋅9=19)\).

题目内部图片:

题意:

给定\(A,B\) 求$ 1≤a≤A, 1≤b≤B1$ 有多少对(a,b)使\(a⋅b+a+b=conc(a,b)\) 成立。

思路:

仔细分解一下所给的公式:

\[a * b + a + b = conc(a,b)\\
a * b + a + b = a * 10^{|num|} + b \\
| num | 是b的十进制表示长度。\\
a * b + a = a * 10^{|num|}\\
b + 1 = 10^{|num|}\\
因此,b总是看起来像99…99。 因此,答案是a *(| num + 1 | -1)。
\]
#include<bits/stdc++.h>
#define ms(a,b) memset(a,b,sizeof a)
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;
const int N = 1e5 + 100;
ll _, n, m, a[N], i, j; void solve() {
ll A, B; cin >> A >> B;
ll weinum = 0, i = B;
bool flag = true;
while (i) {
weinum++;
i /= 10;
}
i = B;
while (i) {
if (i % 10 != 9) {
flag = false;
break;
}
i /= 10;
}
if (flag)cout << A * weinum << endl;
else cout << A * (weinum - 1) << endl;
} int main() {
//freopen("in.txt", "r", stdin);
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> _; while (_--) solve();
}
#python
for t in range(int(input())):
a, b = map(int, input().split())
print(a * (len(str(b + 1)) - 1))

1288C - Two Arrays

组合数学问题。

让我们考虑以下顺序:

\[a_1,a_2,…,a_m,b_m,b_{m-1},…,b_1。
\]

它的长度为$ 2m \(的序列以降序排列,其中每个序列的每个元素都是\) 1 \(和\) n $之间的整数。

我们可以通过简单的组合来找到此类序列的数量-它是与重复结合在一起的。 所以答案是

\[\begin{pmatrix}n+2m−1\\\\2m\end{pmatrix} = (n+2m−1)!(2m)!/(n−1)!
\]
#python
from math import factorial as fact
mod = 10**9 + 7 def C(n, k):
return fact(n) // (fact(k) * fact(n - k)) n, m = map(int, input().split())
print(C(n + 2*m - 1, 2*m) % mod)

1288D - Minimax Problem

思路:来自CF官网

我们将使用二进制搜索来解决该问题。 假设我们想知道答案是否不少于x。

每个数组都可以由一个m位掩码表示,其中如果数组的第i个元素不少于x,则第i个位为1;如果第i个元素小于x,则第i个位为0。 如果要验证答案不小于x,则必须选择两个数组,使它们的掩码的按位或为\(2^m-1\)。

检查所有成对的数组太慢。 取而代之的是,我们可以将相同掩码表示的数组视为相等-这样,我们将不会有超过\(2^m\)个不同的数组,并且可以迭代\(4^m\)对。 总体而言,该解决方案在\(O(logA(4^m + nm))\)下工作。

C++代码实现:

#include<bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int> > a;
int a1, a2; bool can(int mid)
{
vector<int> msk(1 << m, -1);
for(int i = 0; i < n; i++)
{
int cur = 0;
for(int j = 0; j < m; j++)
if(a[i][j] >= mid)
cur ^= (1 << j);
msk[cur] = i;
}
if(msk[(1 << m) - 1] != -1)
{
a1 = a2 = msk[(1 << m) - 1];
return true;
}
for(int i = 0; i < (1 << m); i++)
for(int j = 0; j < (1 << m); j++)
if(msk[i] != -1 && msk[j] != -1 && (i | j) == (1 << m) - 1)
{
a1 = msk[i];
a2 = msk[j];
return true;
}
return false;
} int main()
{
scanf("%d %d", &n, &m);
a.resize(n, vector<int>(m));
for(int i = 0; i < n; i++)
for(int j = 0; j < m; j++)
scanf("%d", &a[i][j]);
int lf = 0;
int rg = int(1e9) + 43;
while(rg - lf > 1)
{
int m = (lf + rg) / 2;
if(can(m))
lf = m;
else
rg = m;
}
assert(can(lf));
printf("%d %d\n", a1 + 1, a2 + 1);
}

Educational Codeforces Round 80 A - D题题解(又是卡很久的一场比赛)的更多相关文章

  1. Educational Codeforces Round 80 A-E简要题解

    contest链接:https://codeforces.com/contest/1288 A. Deadline 题意:略 思路:根据题意 x + [d/(x+1)] 需要找到一个x使得上式小于等于 ...

  2. Educational Codeforces Round 80 (Rated for Div. 2)部分题解

    A. Deadline 题目链接 题目大意 给你\(n,d\)两个数,问是否存在\(x\)使得\(x+\frac{d}{x+1}\leq n\),其中\(\frac{d}{x+1}\)向上取整. 解题 ...

  3. Educational Codeforces Round 37-F.SUM and REPLACE题解

    一.题目 二.题目链接 http://codeforces.com/contest/920/problem/F 三.题意 给定$N$个范围在$[1, 1e6)$的数字和$M$个操作.操作有两种类型: ...

  4. Educational Codeforces Round 80 (Rated for Div. 2)

    A. Deadline 题目链接:https://codeforces.com/contest/1288/problem/A 题意: 给你一个 N 和 D,问是否存在一个 X , 使得 $x+\lce ...

  5. Educational Codeforces Round 80 C. Two Arrays(组合数快速取模)

    You are given two integers nn and mm . Calculate the number of pairs of arrays (a,b)(a,b) such that: ...

  6. Educational Codeforces Round 80 (Rated for Div. 2)D E

    D枚举子集 题:https://codeforces.com/contest/1288/problem/D题意:给定n个序列,每个序列m个数,求第i个和第j个序列组成b序列,b序列=max(a[i][ ...

  7. Educational Codeforces Round 37-G.List Of Integers题解

    一.题目 二.题目链接 http://codeforces.com/contest/920/problem/G 三.题意 给定一个$t$,表示有t次查询.每次查询给定一个$x$, $p$, $k$,需 ...

  8. Educational Codeforces Round 23 A-F 补题

    A Treasure Hunt 注意负数和0的特殊处理.. 水题.. 然而又被Hack了 吗的智障 #include<bits/stdc++.h> using namespace std; ...

  9. Educational Codeforces Round 12 B C题、

    B. Shopping 题意:n个顾客,每个顾客要买m个物品,商场总共有k个物品,看hint就只知道pos(x)怎么算了,对于每一个Aij在k个物品中找到Aij的位置.然后加上这个位置对于的数值,然后 ...

  10. Educational Codeforces Round 10 A B题、

    A. Gabriel and Caterpillar 题意: 就是说  一个小孩子去观察毛毛虫从 h1的地方爬到h2的地方.毛毛虫从10点爬到22点.每小时爬的距离是a, 晚上22点到第二天早上10点 ...

随机推荐

  1. 【VMware vSAN】主机之间网络性能测试,提示“无法运行网络性能测试。请稍后重试。”的处理过程。

    vSAN集群监控,有一个主动测试功能,里面可以针对vSAN主机进行虚拟机创建测试.网络性能测试等. 官方解释: 虚拟机创建测试通常需要 20 至 40 秒时间,在超时情况下最长需要 180 秒时间.将 ...

  2. i-MES生产制造管理系统-SMT物料防错与追溯

    说起 SMT,相信大家或多或少都有一些了解,主要是用来贴片的,简单点说就是给空白的 PCB 板贴上一些元器件,比如二极管.IC.电阻等等各种电子元器件,以前客户对这些元器件物料的追溯管控的并不严格,只 ...

  3. CICD实践1:环境安装篇

    一.CICD技术选型 配置管理工具 工具 需求管理工具 使用禅道 代码管理工具 使用Gitlab 编译构建工具 搭建Jenkins,使用Jenkinsfile 制品库工具 nexus 文档管理工具 C ...

  4. 2023 年最后一波工具安利「GitHub 热点速览」

    2023 年还有两周就要接近尾声了,2023 年的热点速览还有一波工具好安利:比如上周推荐之后上了热榜的远程调试工具 page-spy-web,让调试像呼吸一般自然方便:还有轻量级的搜索引擎 oram ...

  5. 阿里云+智能ai+gpt

    1.阿里 百度 腾讯分词 知识库.     阿里云(项目具体的费用预算展示,实际功能核算.) 向量智库 https://developer.aliyun.com/article/1234278?spm ...

  6. Java8函数式编程应用

    我们经常提到,Java8是革命性的一个版本,原因就是正式引入了函数式编程,那Java的函数式编程在实际应用中到底有什么用呢?结合实际的应用,我整理出了函数式在Java的几个经典用途. 缓求值 惰性求值 ...

  7. 从零玩转QQ登录-clwzqqdlu

    title: 从零玩转QQ登录 date: 2021-05-01 15:55:39.951 updated: 2023-03-30 13:29:03.865 url: https://www.yby6 ...

  8. Java 并发编程(三)锁与 AQS

    本文 JDK 对应的版本为 JDK 13 由于传统的 synchronized 关键字提供的内置锁存在的一些缺点,自 JDK 1.5 开始提供了 Lock 接口来提供内置锁不具备的功能.显式锁的出现不 ...

  9. ubuntu 之 lftp 上传 和下载

    1. 安装 sudo apt-get install lftp 2. 简单教程 2.0 声明:上传或下载文件 用get 或 mget,这种方式 不包含文件夹本身,如果需要连文件夹一起上传或下载则需要使 ...

  10. 全量通过,华为云GaussDB首批完成信通院全密态数据库评测

    摘要:100%全量通过!基于全栈创新计算架构的全密态数据库华为云GaussDB,完成了中国信通院组织的首批"全密态数据库"产品能力评测. 本文分享自华为云社区<全量通过!华为 ...