链接

签到题,求出位数,然后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;
}

未完待续~

最新文章

  1. android OnTouchListener 按下与抬起
  2. 转载:Chrome调试折腾记_(1)调试控制中心快捷键详解!!!
  3. svn还原到指定版本
  4. 【linux】配置SSH免密码登陆
  5. 我是如何使用git的
  6. DIV设置了固定宽高出现文字(文本)的不能自动换行
  7. oracle分区表(整理)
  8. vi编辑器的三种模式
  9. Request Connection: Remote Server @ 192.229.145.200:80
  10. Unix/Linux环境C编程入门教程(42) 终端控制篇
  11. FrameBuffer系列 之 一点资源
  12. 前端使用d3.js调用地图api 进行数据可视化
  13. Mac os x下几款mysql客户端
  14. PHP常用设计模式讲解
  15. 亚马逊AWS免费套餐EC2安装centos连接登录并创建root
  16. k8s实战
  17. 4.《python自省指南》学习
  18. tab menu
  19. 使用GitBook, Git github, Markdown 快速发布你的书籍
  20. activiti整合开发实例总结

热门文章

  1. 2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛
  2. AcWing&#160;21.&#160;斐波那契数列
  3. Salesforce 开发整理(一)测试类最佳实践
  4. js input radio点击事件
  5. PHP 7.4.0 发布
  6. RPA 可以给医疗行业带来哪些好处
  7. 关于 ASP.NET Core 中的 RazorPages
  8. KiRaiseException函数逆向
  9. 在IDEA中用Maven打包大项目时失败问题
  10. Spring Boot快速集成kaptcha生成验证码