Codeforces Round #690 (Div. 3) (简单题解记录)
Codeforces Round #690 (Div. 3)
1462A. Favorite Sequence
简单看懂题即可,左边输出一个然后右边输出一个。
void solve() {
int n;
cin >> n;
vector<ll> a(n + 1);
// ll a[n + 1]; //两种写法均可
for (int i = 1; i <= n; ++i)
cin >> a[i];
int l = 1, r = n;
bool f = true;
for (int i = 1; i <= n; ++i) {
if (f)
cout << a[l++] << " ", f = false;
else
cout << a[r--] << " ", f = true;
}
cout << endl;
}
1462B. Last Year's Substring
一开始想错了,正确的思路是拆分字符串看是否能组成 2020
void solve() {
int n;
string s;
cin >> n >> s;
bool f = false;
for (int fir = 0; fir <= 4 && !f; fir++) {
int sec = 4 - fir; //定位
if (s.substr(0, fir) + s.substr(n - sec) == "2020")
f = true;
}
cout << (f ? "YES\n" : "NO\n");
}
1462C. Unique Number
打表。注意一下n > 45的话直接输出-1(因为0~9都被使用了最多到45)
ll a[51] = {
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 19, 29, 39, 49, 59, 69,
79, 89, 189, 289, 389, 489, 589, 689,
789, 1789, 2789, 3789, 4789, 5789, 6789, 16789,
26789, 36789, 46789, 56789, 156789, 256789, 356789, 456789,
1456789, 2456789, 3456789, 13456789, 23456789, 123456789, -1, -1,
-1, -1, -1,
};
void solve() {
int n, cnt = 0;
string s;
cin >> n;
cout << a[n] << endl;
}
当然也可以正常分析:
void solve() {
int n;
cin >> n;
if (n > 45) {
cout << -1 << endl;
return;
}
string s;
int nxt = 9;
while (n > 0) {
if (n >= nxt) {
s += '0' + nxt;
n -= nxt--;
} else {
s += '0' + n;
break;
}
}
reverse(s.begin(), s.end());
cout << s << endl;
}
D. Add to Neighbour and Remove
void solve() {
int n;
cin >> n;
vector<ll> a(n);
for (int i = 0; i < n; ++i)
cin >> a[i];
ll ans = INT_MAX, sum = 0;
for (int i = 0; i < n; ++i) {
sum += a[i];
ll cur = 0, toadd = 0;
bool f = true;
for (int j = 0; j < n; ++j) {
if (cur)
toadd++;
cur += a[j];
if (cur > sum) {
f = false;
break;
} else if (cur == sum)
cur = 0;
}
if (f && cur == 0) {
// cout << toadd << " " << i << endl;
ans = min(ans, toadd);
}
}
cout << ans << endl;
}
E1. Close Tuples (easy version)
//unsolved
Codeforces Round #690 (Div. 3) (简单题解记录)的更多相关文章
- # Codeforces Round #529(Div.3)个人题解
Codeforces Round #529(Div.3)个人题解 前言: 闲来无事补了前天的cf,想着最近刷题有点点怠惰,就直接一场cf一场cf的刷算了,以后的题解也都会以每场的形式写出来 A. Re ...
- Codeforces Round #557 (Div. 1) 简要题解
Codeforces Round #557 (Div. 1) 简要题解 codeforces A. Hide and Seek 枚举起始位置\(a\),如果\(a\)未在序列中出现,则对答案有\(2\ ...
- Codeforces Round #538 (Div. 2) (A-E题解)
Codeforces Round #538 (Div. 2) 题目链接:https://codeforces.com/contest/1114 A. Got Any Grapes? 题意: 有三个人, ...
- Codeforces Round #531 (Div. 3) ABCDEF题解
Codeforces Round #531 (Div. 3) 题目总链接:https://codeforces.com/contest/1102 A. Integer Sequence Dividin ...
- Codeforces Round #499 (Div. 1)部分题解(B,C,D)
Codeforces Round #499 (Div. 1) 这场本来想和同学一起打\(\rm virtual\ contest\)的,结果有事耽搁了,之后又陆陆续续写了些,就综合起来发一篇题解. B ...
- Codeforces Round #540 (Div. 3) 部分题解
Codeforces Round #540 (Div. 3) 题目链接:https://codeforces.com/contest/1118 题目太多啦,解释题意都花很多时间...还有事情要做,就选 ...
- Codeforces Round #527 (Div. 3) ABCDEF题解
Codeforces Round #527 (Div. 3) 题解 题目总链接:https://codeforces.com/contest/1092 A. Uniform String 题意: 输入 ...
- Codeforces Round #624 (Div. 3)(题解)
Codeforces Round #624 (Div.3) 题目地址:https://codeforces.ml/contest/1311 B题:WeirdSort 题意:给出含有n个元素的数组a,和 ...
- Codeforces Round #821(Div.2) (A-C) 题解
Codeforces Round #821(Div.2) (A-C) A.Consecutive Sum 大致题意 给定一组共 n 个数据 ,如果俩个数的下标在 mod k 意义下同余,则可以交换a[ ...
- Codeforces Round #545 (Div. 1) 简要题解
这里没有翻译 Codeforces Round #545 (Div. 1) T1 对于每行每列分别离散化,求出大于这个位置的数字的个数即可. # include <bits/stdc++.h&g ...
随机推荐
- Android学习day01【搭建Android Studio】
是Google开发的操作系统 Android开发是移动应用开发的表现形式之一 还有很多的开发形式,就不一一列举了 完整项目精简的开发流程 开发工具 Android studio(强烈建议) Andro ...
- [CF1229E]Marek and Matching
This is a harder version of the problem. In this version, \(n \le 7\). Marek is working hard on crea ...
- [ABC233G] Strongest Takahashi
Problem Statement There is a $N \times N$ grid, with blocks on some squares. The grid is described b ...
- C# 常量 结构体 委托
常量 const double PI = 3.1415926; 常量名命名一般使用大写字母 枚举类型 开发一个游戏,游戏角色有法师(Mage).射手(Archer).刺客(Assassin).坦克(T ...
- Arrarylist集合的使用
前提:最近JAVA实训课老师讲了一些Arrarylist集合的相关知识,刚好端午假期有空就把这课上学到的知识和自己碰到的一些问题总结下来. 一.Arrarylist集合的使用(以学生信息存储作为演示) ...
- MyBatisPlus-使用步骤
MyBatisPlus-使用步骤 第一步 引入maven坐标依赖 <dependency> <groupId>com.baomidou</groupId> < ...
- Ef Core花里胡哨系列(10) 动态起来的 DbContext
Ef Core花里胡哨系列(10) 动态起来的 DbContext 我们知道,DbContext有两种托管方式,一种是AddDbContext和AddDbContextFactory,但是呢他们各有优 ...
- 某物流客户Elasticsearch集群性能优化案例
客户背景 客户使用ES来进行数据存储.快速查询业务订单记录,但是经常会出现业务高峰期ES集群的cpu负载.内存使用均较高,查询延迟大,导致前端业务访问出现大量超时的情况,极大影响其客户使用体验. 部分 ...
- PythonAnywhere 部署Flask项目
一. 注册账号 官网:https://www.pythonanywhere.com/ 二. 将GitHub上的项目发送至PythonAnywhere 三.配置环境及运行 git clone https ...
- 十分钟教你在 k8s 中部署一个前后端应用
转载至我的博客https://www.infrastack.cn ,公众号:架构成长指南 大家好,我是蜗牛哥,好多开发人员,尤其是没接触过 k8s 的人员对如何在k8s中部署一个 前后端应用很模糊,不 ...