Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)
签到题,求出位数,然后9*(位数-1)+ 从位数相同的全一开始加看能加几次的个数
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
int t;
int y;
cin>>t;
int ans = 0;
while(t--)
{
cin>>y;
ans = 0;
int weishu = 0;
int temp = y;
while(temp>0)
{
weishu++;
temp/=10;
}
ans += (weishu-1)*9;
temp = 1;
for (int i = 1; i < weishu; ++i)
{
temp = temp*10+1;
}
for (int i = temp; i <= y; i += temp)
{
ans++;
}
cout<<ans<<endl;
}
return 0;
}
思路,用堆来维护所有的偶数,每次取最大的来除以二,但是需要在处理的时候去重。用STL的优先队列就可
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
//数的数量啊
//排序一波?
priority_queue<int> q;
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int num;
int flag = 0;
for (int i = 0; i < n; ++i)
{
cin>>num;
if (!(num%2)) //不是奇数,插入就行
{
q.push(num);
flag++;
}
}
if(flag)
{
int top = q.top();
int ans = 0;
int cur = 0;
q.pop();
ans++;
if (!((top/2)%2))
{
q.push(top/2);
}
while(!q.empty())
{
cur = q.top();
//cout<<cur<<endl;
q.pop();
if (cur == top)
continue;
else //不是重复了哈
{
top = cur;
ans++;
if (!((top/2)%2))
{
q.push(top/2);
}
}
}
cout<<ans<<endl;
}
else
cout<<"0"<<endl;
}
return 0;
}
思考一下,因为two和one,是可能出现连起来出现的,所以先扫描一遍所有的twone这种的,去掉中间的o,然后再扫描一次把剩下的one和two
去掉中间那个字母就行。
#include<bits/stdc++.h>
using namespace std;
char s[150001];
int del[150001];
int main(int argc, char const *argv[])
{
ios::sync_with_stdio(false);
std::vector<int> a;
int t;
cin>>t;
while(t--)
{
cin>>s;
int ans = 0;
a.clear();
//memset(del, 0, sizeof(del));
int len = strlen(s);
for (int i = 0; i < len; ++i)
{
del[i]=0;
}
for (int i = 2; i < len-2; ++i)
{
if (s[i]=='o')
{
if (s[i-2]=='t'&&s[i-1]=='w'&&s[i+1]=='n'&&s[i+2]=='e')
{
//s.erase(i,1);
a.push_back(i+1);
del[i] = 1;
//cout<<i<<" ";
++ans ;
}
}
}
for (int i = 1; i <=len-2; ++i)
{
if (s[i]=='w')
{
if (s[i-1]=='t'&&s[i+1]=='o'&&!del[i+1])
{
del[i]=1;
a.push_back(i+1);
++ans;
//cout<<i<<" ";
}
}
if (s[i]=='n')
{
if (s[i-1]=='o'&&s[i+1]=='e'&&!del[i-1])
{
del[i]=1;
a.push_back(i+1);
++ans;
//cout<<i<<" ";
}
}
}
cout<<ans<<endl;
for (int i = 0; i < ans; ++i)
{
cout<<a[i]<<' ';
}
cout<<endl;
}
return 0;
}
未完待续~
Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)的更多相关文章
- 【cf比赛记录】Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)
比赛传送门 只能说当晚状态不佳吧,有点头疼感冒的症状.也跟脑子没转过来有关系,A题最后一步爆搜没能立即想出来,B题搜索没有用好STL,C题也因为前面两题弄崩了心态,最后,果然掉分了. A:简单数学 B ...
- 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 #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 #602 (Div. 2, based on Technocup 2020 Elimination Round 3
A,有多个线段,求一条最短的线段长度,能过覆盖到所又线段,例如(2,4)和(5,6) 那么我们需要4 5连起来,长度为1,例如(2,10)(3,11),用(3,10) 思路:我们想一下如果题目说的是最 ...
- 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 #596 (Div. 2, based on Technocup 2020 Elimination Round 2) C. p-binary
链接: https://codeforces.com/contest/1247/problem/C 题意: Vasya will fancy any number as long as it is a ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) B2. TV Subscriptions (Hard Version)
链接: https://codeforces.com/contest/1247/problem/B2 题意: The only difference between easy and hard ver ...
- Codeforces Round #596 (Div. 2, based on Technocup 2020 Elimination Round 2) A. Forgetting Things
链接: https://codeforces.com/contest/1247/problem/A 题意: Kolya is very absent-minded. Today his math te ...
随机推荐
- 设计模式-Decorator(结构型模式) 用于通过 组合 的方式 给定义的类 添加新的操作,这里不用 继承 的原因是 增加了系统的复杂性,继承使深度加深。
以下代码来源: 设计模式精解-GoF 23种设计模式解析附C++实现源码 //Decorator.h #pragma once class Component { public: virtual ~C ...
- 新工具解决消息丢失的bug
最近在调查一个消息丢失的bug,所幸客户的文本文件里有丢失的记录,但在localdb文件里找不到. 我当时的想法是,在运行report的时候把丢失的记录从文本文件找出来,然后添加到localdb里,最 ...
- Socket抽象层
目录 一.Socket抽象层 一.Socket抽象层 我们知道两个进程如果需要进行通讯最基本的一个前提是能够唯一标示一个进程,在本地进程通讯中我们可以使用PID来唯一标示一个进程,但PID只在本地唯一 ...
- js获取url参数值的方法总结
1.方式一:通过字符串截取的方式获取参数值: 1).函数一:获取URL中的参数名及参数值的集合 /** * [获取URL中的参数名及参数值的集合] * 示例URL:http://htmlJsTest/ ...
- swoole4创建Mysql连接池
一 .什么是mysql连接池 场景:每秒同时有1000个并发,但是这个mysql同时只能处理400个连接,mysql会宕机. 解决方案:连接池,这个连接池建立了200个和mysql的连接,这100 ...
- IT兄弟连 HTML5教程 介绍HTML5给你认识 习题
1.关于HTML5说法正确的是:(C) A.HTML5只是对HTML4的一个简单升级 B.所有主流浏览器都支持HTML5 C.HTML5新增了离线缓存机制 D.HTML5主要是针对移动端进行了优化 2 ...
- day01(无用)
第一讲:1,基本理论知识 第一天内容:抽象.枯燥. 2,工具的操作: 三个工具: 2个发包工具: Jmeter.PostMan 1个抓包工具: Fiddler 3,安全测试的内容: 初级,工具的使用: ...
- bash / powershell切换到脚本所在目录
切换工作目录到脚本所在目录 bash: #!/usr/bin/env sh cd $(dirname $0) #cd $(dirname $(readlink $0)) #soft link powe ...
- linux远程执行ssh禁用交互方法
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ${user}@${ip} ${cmd}
- 抖音美女千千万,想用Python爬爬看
前言 文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理. 作者: 星安果.AirPython PS:如有需要Python学习资料的小伙 ...



