【cf比赛记录】Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)
比赛传送门
只能说当晚状态不佳吧,有点头疼感冒的症状。也跟脑子没转过来有关系,A题最后一步爆搜没能立即想出来,B题搜索没有用好STL,C题也因为前面两题弄崩了心态,最后,果然掉分了。
A:简单数学
B:数学+排序
C:字符串搜索
A
// https://codeforces.com/contest/1277/problem/A
/*
题意:
给出一个数,求不大于该数的完美整数的个数(完美整数指全是一个数组成的数字,如:111, 333333, 444444, 9, 8888 ...)
分析:
因为求不大于的,那位数小于当前数的肯定满足,所以可以先得到 ans = (位数 - 1) * 9
然后就从同位的完美整数开始比较,比当前数小的就 ans++
因为数最大是 1e9, 我用 char[1e9] MLE 了...
*/
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
long long n[20][20];
int T;
long long num;
// 完美整数打表
void init(){
for(int i = 1; i <= 10; i++){
for(int j = 1; j <= 10; j++){
n[i][j] = n[i - 1][j] * 10 + j;
}
}
}
int main()
{
init();
scanf("%d", &T);
while(T--){
long long ans = 0;
scanf("%I64d", &num);
if(num < 10) ans = num;
else {
int len = 0;
for(int i = num; i; i /= 10) len++; // 求当前数的位数
ans += (len - 1) * 9;
// 最高位的遍历
for(int i = 1; i <= 9; i++){
if(n[len][i] <= num) {
ans++;
}
}
}
printf("%I64d\n", ans);
}
return 0;
}
//2
//1000000000
//999999999
B
// https://codeforces.com/contest/1277/problem/B
/*
题意:
在 n 个数里,把偶数都除以二,直至除到全为奇数为止,相同的偶数可以同时进行,问最少步可以除完
分析:
既然相同的偶数可以同时进行,那就找最后奇数相同的时候,它是2的倍数时最大的那个数的步骤数就行
例如 6 与 12 的话,只需要知道 12 除 2 除到奇数时需要 2 次即可 ==== 12 / 2 = 6, 两个 6 同时除以 2 就是 3
关键是怎么记录这些偶数对应的奇数 ---- 选好STL很关键,我比赛时选了个数组遍历已存的奇数而超时了,补题用map就很舒服 109ms,比我朋友 500多ms 要快
先排序,从大的先找,用map存奇数,当已经有奇数k存在时,就不需要计算当前的偶数了
*/
#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
using namespace std;
// two:存 2 的次方数 num:存 n 个数据
int two[40], num[200005];
int T, n, cnt;
void init_two(){
two[0] = 1;
for(int i = 1; i <= 32; i++){
two[i] = two[i - 1] * 2;
}
}
int main()
{
init_two(); // 打表
scanf("%d", &T);
while(T--){
scanf("%d", &n);
for(int i = 0; i < n; i++) scanf("%d", &num[i]);
sort(num, num + n); // 排序
int ans = 0;
map<int, int> m;
for(int i = n - 1; i >= 0; i--){ // 从大往小找
int tmp = num[i];
if(tmp & 1) continue; // 如果是奇数就跳过
for(int t = 30; t >= 1; t--){ // 2 的次方数也是从大往小找
if(tmp % two[t] == 0){ // 此时能整除的时候就是所需要的步数
int k = tmp / two[t];
// printf("k:%d m:%d\n", k, m[k]);
if(m[k]) break; // 如果 k 已经存在则不用计算
m[k]++;
ans += t;
break;
}
}
}
printf("%d\n", ans);
}
return 0;
}
C
// https://codeforces.com/contest/1277/problem/C
/*
题意:
给一个字符串,要求剔除字符串里的最少个字符,使其中不含"one","two"两个子序列
输出需要剔除字符的最少个数以及它们所在的位置
分析:
有三种情况,分别是 "one", "two", "twone"
最后一种比较好理解,直接去掉中间的 'o' 就不存在 "two" 与 "one" 了
而"one"与"two"情况时一样处理,剔除中间那位,因为像 "oone" 这种的话,剔除前面的'o'要剔除两次(后面的'e'亦然)
整体比较暴力
*/
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int T;
char ch[150005];
int ans[50004];
int main()
{
scanf("%d", &T);
while(T--){
int cnt = 0;
scanf("%s", ch);
int len = strlen(ch) - 2;
for(int i = 0; i < len; i++){
if(ch[i] == 'o' && ch[i + 1] == 'n' && ch[i + 2] == 'e') { // one 的情况
ans[cnt++] = i + 2;
i += 2;
}
else if(ch[i] == 't' && ch[i + 1] == 'w' && ch[i + 2] == 'o'){ // two 的情况
if(ch[i + 3] == 'n' && ch[i + 4] == 'e'){ // twone 的情况
ans[cnt++] = i + 3;
i += 4;
}
else {
ans[cnt++] = i + 2;
i += 2;
}
}
}
printf("%d\n", cnt);
for(int i = 0; i < cnt; i++){
if(i != 0) printf(" ");
printf("%d", ans[i]);
}
printf("\n");
}
return 0;
}
记录菜鸟的成长过程:

最后唠叨几句:
周日(12月15日)没有打CF两场比赛,而是去广州找我三位好基友玩耍了(两名是广工的学生,一名是华南理工的学生)。其中一位是复读才考上了广工的机械类专业的。现在他是大一生的身份去参加了一个社团组织,去做机器人。当天他带我们参观了他们的实验室,实验室里还有两位大三的师兄在备考明年的考研。他们要做成的机器人至少需要三个专业的学生协同配合,其中一位就需要计算机专业类的学生负责写代码一方面。听他的描述,写代码需要与摄像头结合起来,要会使用单片机等等与硬件相结合的东西。听得我着实有点羡慕,也引起了我的思考。
好强的大一生,像广工这等高校里面的人都这么强吗?越发觉得自己一直在摸鱼。学校的环境是改不了,但自己可以改变的吧?办法总比困难多。
再次意识到自己与外面的差距,即便在自己本校里,自己与校内的dalao也有很大的差距。
要继续努力才行。
【cf比赛记录】Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)的更多相关文章
- 20191214 Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)
概述 切了 ABCE,Room83 第一 还行吧 A - Happy Birthday, Polycarp! 题解 显然这样的数不会很多. 于是可以通过构造法,直接求出 \([1,10^9]\) 内所 ...
- Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4) 题解
Happy Birthday, Polycarp! Make Them Odd As Simple as One and Two Let's Play the Words? Two Fairs Bea ...
- Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)
链接 签到题,求出位数,然后9*(位数-1)+ 从位数相同的全一开始加看能加几次的个数 #include<bits/stdc++.h> using namespace std; int m ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2)
A - Forgetting Things 题意:给 \(a,b\) 两个数字的开头数字(1~9),求使得等式 \(a=b-1\) 成立的一组 \(a,b\) ,无解输出-1. 题解:很显然只有 \( ...
- Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) D. Sequence Sorting
链接: https://codeforces.com/contest/1241/problem/D 题意: You are given a sequence a1,a2,-,an, consistin ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) D. Power Products
链接: https://codeforces.com/contest/1247/problem/D 题意: You are given n positive integers a1,-,an, and ...
- Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) C. Save the Nature【枚举二分答案】
https://codeforces.com/contest/1241/problem/C You are an environmental activist at heart but the rea ...
- Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) C. Save the Nature
链接: https://codeforces.com/contest/1241/problem/C 题意: You are an environmental activist at heart but ...
- Codeforces Round #602 (Div. 2, based on Technocup 2020 Elimination Round 3
A,有多个线段,求一条最短的线段长度,能过覆盖到所又线段,例如(2,4)和(5,6) 那么我们需要4 5连起来,长度为1,例如(2,10)(3,11),用(3,10) 思路:我们想一下如果题目说的是最 ...
随机推荐
- csrf攻击与csrf防御
CSRF(Cross-site request forgery)跨站请求伪造,也被称为“One Click Attack”或者Session Riding,通常缩写为CSRF或者XSRF,是一种对网站 ...
- python做中学(一)全局变量的用法
一段时间没有使用python来写代码,就发现以前学习的很多语法都忘了.看来还是当初这方面的项目做的好不够多,没有系统性的运用和学习,导致了很多语法不能顺手拈来.在接下来的这个项目中, 一定要把遇到的一 ...
- IT兄弟连 Java语法教程 注释与编码规范
在程序代码中适当地添加注释可以提高程序的可读性和可维护性.好的编码规范可以使程序更易阅读和理解.下面将介绍Java中的集中代码注释以及应该注意的编码规范. 代码注释 通过在程序代码中添加注释可提高程序 ...
- php-laravel框架用户验证(Auth)模块解析(一)
一.初始化 使用php artisan命令进行初始化:php artisan make:auth 和 php artisan migrate(该命令会生成users表.password_resets表 ...
- 让iphone5s 支持 flex 布局
/* Center slide text vertically */display: -webkit-box;display: -ms-flexbox;display: -webkit-flex;di ...
- spring-boot-starter-web排除自带的logback依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring- ...
- docker 集群管理gui
k8s: https://www.rancher.cn/ swarm: https://github.com/dockersamples/docker-swarm-visualizer https:/ ...
- 数据库之MySQL查询
查询 创建数据库.数据表 -- 创建数据库 create database python_test1 charset=utf8; -- 使用数据库 use python_test1; -- stude ...
- C# Task ContinueWith
static void Main(string[] args) { Task firstTask = Task.Run(() => { PrintPlus(); }); Task secondT ...
- pycharm 取消连按两下shift出现的全局搜索
在来回切换中英文输入法的时候连按两下shift总是会蹦出来全局搜索框 真的很是麻烦,现在是把这个框给禁用掉 1.按ctrl+shift+a,弹出搜索框2.输入registry,然后按回车3.找到“id ...