链接

签到题,求出位数,然后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)的更多相关文章

  1. 【cf比赛记录】Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)

    比赛传送门 只能说当晚状态不佳吧,有点头疼感冒的症状.也跟脑子没转过来有关系,A题最后一步爆搜没能立即想出来,B题搜索没有用好STL,C题也因为前面两题弄崩了心态,最后,果然掉分了. A:简单数学 B ...

  2. 20191214 Codeforces Round #606 (Div. 2, based on Technocup 2020 Elimination Round 4)

    概述 切了 ABCE,Room83 第一 还行吧 A - Happy Birthday, Polycarp! 题解 显然这样的数不会很多. 于是可以通过构造法,直接求出 \([1,10^9]\) 内所 ...

  3. 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 ...

  4. 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. 题解:很显然只有 \( ...

  5. 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) 思路:我们想一下如果题目说的是最 ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. Linux下新增和使用系统调用

    关键词:__SYSCALL().SYSCALL_DEFINEx().syscall()等等. 1. 为什么使用syscall 内核和用户空间数据交换有很多种方式:sysfs.proc.信号等等. 但是 ...

  2. Mac打开Finder快捷键

    摘要:目前网络中较常见的打开Finder的方法有两种,要么是先进入桌面状态,再使用快捷键command + shift + c:要么是通过下载软件来设置打开Finder的快捷键.都过于繁琐,其实有很简 ...

  3. 0day2安全——笔记1

    第一章 PE和内存之间的映射 节偏移 文件偏移地址(File Offset Address):数据在PE文件中的地址 装载地址(Image Base):PE装入内存的基地址 虚拟内存地址(Virtua ...

  4. 算法问题实战策略 PICNIC

    下面是另一道搜索题目的解答过程题目是<算法问题实战策略>中的一题oj地址是韩国网站 连接比较慢 https://algospot.com/judge/problem/read/PICNIC ...

  5. 浅谈C++ STL list 容器

    浅谈C++ STL list 容器 本篇随笔简单讲解一下\(C++STL\)中\(list\)容器的使用方法和使用技巧. list容器的概念 学习过\(C++STL\)的很多同学都知道,\(STL\) ...

  6. 一道常被人轻视的web前端常见面试题(JS)

    本文转载自站长之家,如有侵权问题,请联系我,马上删除. 面试题是招聘公司和开发者都非常关心的话题,公司希望通过它了解开发者的真实水平和细节处理能力,而开发者希望能够最大程度地展示自己的水平(甚至超常发 ...

  7. event.stopPropagation()和event.preventDefault()

    1.event.stopPropagation()方法 这是阻止事件的冒泡方法,不让事件向documen上蔓延,但是默认事件任然会执行,当你掉用这个方法的时候,如果点击一个连接,这个连接仍然会被打开, ...

  8. 从Python安装到语法基础,这才是初学者都能懂的爬虫教程

    Python和PyCharm的安装:学会Python和PyCharm的安装方法 变量和字符串:学会使用变量和字符串的基本用法 函数与控制语句:学会Python循环.判断语句.循环语句和函数的使用 Py ...

  9. python 各层级目录下的import方法

    ---恢复内容开始--- 以前经常使用python2.现在很多东西都切换到了python3,发现很多东西还是存在一些差异化的.跨目录import是常用的一种方法,并且有不同的表现形式,新手很容易搞混. ...

  10. 【shell脚本】点名器===randomName.sh

    随机点名,从name.txt文件中读取名字 [root@VM_0_10_centos shellScript]# cat randowName.sh #!/bin/bash # 随机点名器 # 需提前 ...