
Codeforces Round #690 (Div. 3) (简单题解记录)
发布日期:2021-05-09 00:12:35
浏览次数:16
分类:博客文章
本文共 2461 字,大约阅读时间需要 8 分钟。
1462A. Favorite Sequence
简单看懂题即可,左边输出一个然后右边输出一个。
void solve() { int n; cin >> n; vectora(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; vectora(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
发表评论
最新留言
能坚持,总会有不一样的收获!
[***.219.124.196]2025年04月03日 22时00分39秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
elementUi源码解析(1)--项目结构篇
2021-05-09
自动遍历测试之Monkey工具
2021-05-09
Nmap扫描工具介绍
2021-05-09
算法笔记:递归、动态规划
2021-05-09
Pytest插件开发
2021-05-09
常用Windows 快捷键
2021-05-09
linux命令-压缩与打包
2021-05-09
ORACLE 11g 生产中高水位线(HWM)处理
2021-05-09
centos 6.x 编译安装 pgsql 9.6
2021-05-09
weblogic 服务器部署SSL证书
2021-05-09
oracle 11g not in 与not exists 那个高效?
2021-05-09
Linux 安装Redis 5.0(以及参数调优)
2021-05-09
html5 Game开发系列文章之 零[开篇]
2021-05-09
为什么阿里巴巴建议集合初始化时,指定集合容量大小
2021-05-09
为什么阿里巴巴要求谨慎使用ArrayList中的subList方法
2021-05-09