题目链接:Codeforces Round 957 (Div. 3)

总结:E不懂,F差一个set去重

A. Only Pluses

fag:枚举

B. Angry Monk

fag:模拟

Solution:分裂的花费为\(a_i - 1\),添加的花费为\(a_i\)。

C. Gorilla and Permutation

fag:思维

Solution:大于等于\(k\)的数,逆序放在最前面,小于等于\(m\)的数,从最后面开始从大到小放,中间的位置任意放剩下的数。

void solve(){
cin >> n >> m >> k;
vector<int> a(n + 1);
int i, l, r; for (i = n, l = 1; i >= k; i --, l ++)
a[l] = i; for (i = m, r = n; i >= 1; i --, r --)
a[r] = i; for (int i = l; i <= r; i ++){
a[i] = ++ m;
} for (int i = 1; i <= n; i ++)
cout << a[i] << " \n"[i == n];
}

D. Test of Love

fag:DP

Solution:考虑如何从上一步转移,跳过来或者游过来。

  • 注意\(m\)的范围,可以直接枚举前\(m\)个格子(赛时没看到范围,用单调队列优化DP做的)
  • 游过来的前提,上一格是水。
void solve(){
cin >> n >> m >> k;
string s;
cin >> s;
s = "$" + s;
deque<int> qu;
vector<int> f(n + 2, INF); f[0] = 0;
qu.push_back(0);
for (int i = 1; i <= n + 1; i ++){
if (s[i] == 'C')
continue;
while (qu.size() && qu.front() + m < i){ // 存储原木的坐标
qu.pop_front();
} if (qu.size())
f[i] = f[qu.front()];
if (s[i - 1] == 'W')
f[i] = min(f[i], f[i - 1] + 1); if (s[i] == 'L'){
while (qu.size() && f[qu.back()] >= f[i])
qu.pop_back();
qu.push_back(i);
}
} if (f[n + 1] > k){
cout << "NO\n";
}
else{
cout << "YES\n";
}
}

E. Novice's Mistake

fag:思维

Desription:给定一个\(n\),求出所有满足条件的\(a, b\)组合。

  • \(1 <= a <= 1e4, 1 <= n <= 100\)
  • \(n * a - b\)等于将\(a\)个字符串\(n\)然后删去末尾\(b\)个字符之后代表的整数
  • \(n * a - b > 0\)

Solution:注意到字符串的操作会影响答案的位数,但是数值计算\(n * a\)最多为\(1e6\)所以最大只有\(6\)位。

  • 我们枚举\(a\),然后枚举答案的位数\(k\),对于每个\(k\)求出一个\(b\),判断当前\(a, b\)是否满足条件

Competing:赛场根本没想到位数的关系

void solve(){
string n;
cin >> n;
vector<pii> ans; for (int a = 1; a <= 10000; a ++){
int len = to_string(stoi(n) * a).size(); // 当前位数
// if (a == 1262)
// debug(len);
for (int k = len; k; k --){
int b = a * n.size() - k;
if (!b)
continue;
int t = 0;
for (int i = 1, j = 0; i <= k; i ++){
if (j == n.size())
j = 0;
t = t * 10 + (n[j ++] - '0');
}
if (t == stoi(n) * a - b){
ans.push_back({a, b});
}
// if (a == 1262 && b == 2519){
// debug(t, stoi(n) * a - b);
// }
}
}
cout << ans.size() << endl;
for (auto [a, b] : ans){
cout << a << " " << b << endl;
}
}

F. Test of Love

fag:思维

Description:有\(n\)个数,给定一个\(x\),将\(n\)个数分为\(k\)个连续区间,每个区间满足任意一个子集的乘积不等于\(x\)。

1 <= n <= 1e5 2 <= x <= 1e5
1 <= a_i <= 2e5

Solution:从前往后模拟当前区间能够得到那些因数(使用set去重),因为因数的个数很少,所以可做

Competing:没考虑到使用\(set\)去重

void solve(){
int x;
cin >> n >> x;
vector<int> a(n);
set<int> v; // 记录当前区间所有可能出现的x的约数
for (int i = 0; i < n; i ++)
cin >> a[i]; int ans = 1;
for (int i = 0; i < n; i ++){
if (x % a[i])
continue;
set<int> tmp;
for (auto j : v){
tmp.ep(a[i] * j); // 记录能够构造出来的数
}
for (auto j : tmp){
if (x % j)
continue;
v.ep(j);
}
if (v.find(x) != v.end()){
ans ++;
v.clear();
}
v.ep(a[i]);
}
cout << ans << endl;
}

Codeforces Round 957 (Div. 3)的更多相关文章

  1. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  2. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  3. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  6. Codeforces Round #262 (Div. 2) 1003

    Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...

  7. Codeforces Round #262 (Div. 2) 1004

    Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...

  8. Codeforces Round #371 (Div. 1)

    A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...

  9. Codeforces Round #268 (Div. 2) ABCD

    CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...

  10. 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts

    题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...

随机推荐

  1. Java灵魂拷问13个为什么,你都会哪些?

    大家好,我是 V 哥.今天看了阿里云开发者社区关于 Java 的灵魂拷问,一线大厂在用 Java 时,都会考虑哪些问题呢,对于工作多年,又没有大厂经历的小伙伴不妨看看,V 哥总结的这13个为什么,你都 ...

  2. NSScrollView 内容显示不正常问题

    NSScrollView 内容显示不正常,顶部没有对齐已经后边有空隙,说明Layout的方式错误,采用了Automatic导致的.需要采用如下布局方式才可以.

  3. 【Flink 日常踩坑】Could not find ExecutorFactory in classpath

    Description 一段简单的 FlinkSQL 程序,在 IDE 中运行没问题,但是 maven 打包后发布到终端启动却报错了. import org.apache.flink.configur ...

  4. 【Azure Function】FTP上传了Python Function文件后,无法在门户页面加载函数的问题

    问题描述 通过FTP的方式,把本地能正常运行的Python Function文件上传到云上后,无法加载函数列表问题. 1:上传 function_app.py,requirements.txt文件到 ...

  5. LR语法分析算法

    LR语法分析器 组成:一个输入,一个输出,状态栈,驱动程序,语法分析表 注意:规约后需要寻找新的符号在栈顶状态上的转换 例如: 状态栈   符号栈       输入 0 5        $id    ...

  6. Google Chrome谷歌浏览器离线/绿色版本安装与彻底卸载

    一.离线安装 1.下载官方最新安装包安装 直接下载链接 Windows 32 位最新稳定版: https://dl.google.com/tag/s/installdataindex/update2/ ...

  7. 使用IntersectionObserver 实现懒加载 && 记录一个懒加载失效的原因

    先说说我实现懒加载失效的一个原因: 是图片没有写高度 猜想是没有给图片高度,所以底层没法进行计算 容器是否出现在视图中 IntersectionObservers作用 提供了一种异步观察目标元素与其祖 ...

  8. MYSQL数据库设计操作规范 ❤️【建议收藏】

    1.背景及其意义 MySQL数据库与 Oracle. SQL Server 等数据库相比,有其内核上的优势与劣势.我们在使用MySQL数据库的时候需要遵循一定规范,扬长避短.本文档旨在帮助或指导数据中 ...

  9. # 为什么要使用 MediatR 的 3 个理由和 1 个不使用它的原因

    为什么要使用 MediatR 的 3 个理由和 1 个不使用它的原因 https://codeopinion.com/why-use-mediatr-3-reasons-why-and-1-reaso ...

  10. 依赖注入在 dotnet core 中实现与使用:5. 使用支持 Unicode 的 HtmlEncoder

    现象 在 ASP.NET Core MVC 中,当在页面中传递了一个包含中文字符串到页面的时候,页面的显示是正常的,但是如果查看页面源码,却看不到中文,变成了一串编码之后的内容. 例如,在页面中直接定 ...