暑假集训第六周contest1
题意:就是讲给出一个数n,让你求最少由多少个像0,1,10,11......这样的二进制数相加构成;样例n=9就是由9个二进制1相加组成,我不懂比赛的时候我为什么没有看懂题目在讲什么;再举个例子吧!n=2333 就有二进制1111,1111,111三个数相加而成;
代码:
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
int n,maxn=;
cin>>n;
while (n>)
{
maxn=max(maxn,n%);
n=n/;
}
cout << maxn << endl;
return ;
}
51Nod - 1289 大鱼吃小鱼
分析:用栈来实现,当鱼儿向右游的时候入栈,向左移的时候,将它与栈顶鱼儿的体积进行比较,当栈非空的时候,把当前鱼儿和栈顶鱼儿的体积进行比较,如果大于栈顶鱼儿,则吃掉栈顶鱼儿,如果小于栈顶鱼儿体积,则被栈顶鱼儿吃掉,听上去很容易的吧!!!不幸的是比赛的时候我又把题目理解成更水的意思了!!!!!
代码:
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<stack>
using namespace std;
int main()
{
int n;
cin>>n;
stack<int>s;
int a,b;
int num=n;
for (int i=;i<=n;i++)
{
cin>>a>>b;
if (b==)
s.push(a);
else if (b==)
{ while (!s.empty())
{
if (a>s.top())
s.pop(),num--;
else
{
num--;
break;
}
}
}
}
cout << num << endl;
}
暑假集训第六周contest1的更多相关文章
- ACM暑假集训第三周小结
这一周学的图论,学了这么些 两种存图的方法:邻接矩阵( map[n][n] ) , 邻接表( headlis[n] , vector<int> G[n] )存图的方法,各有各的好,我的理解 ...
- 集训第六周 古典概型 期望 D题 Discovering Gold 期望
Description You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell o ...
- 集训第六周 O题
Description Gerald got a very curious hexagon for his birthday. The boy found out that all the angle ...
- 集训第六周 M题
Description During the early stages of the Manhattan Project, the dangers of the new radioctive ma ...
- 集训第六周 矩阵快速幂 K题
Description In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. F ...
- 集训第六周 数学概念与方法 计数 排列 L题
Description 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了! 做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样. 话 ...
- 集训第六周 数学概念与方法 J题 数论,质因数分解
Description Tomorrow is contest day, Are you all ready? We have been training for 45 days, and all g ...
- 集训第六周 数学概念与方法 数论 线性方程 I题
Description The Sky is Sprite. The Birds is Fly in the Sky. The Wind is Wonderful. Blew Throw the Tr ...
- 集训第六周 数学概念与方法 概率 N题
N - 概率 Time Limit:4000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit Status ...
随机推荐
- day60-mysql-正则表达式
.正则表达式: 8.1 ^ 匹配 name 名称 以 "e" 开头的数据 select * from person where name REGEXP '^e'; 8.2 $ 匹配 ...
- echars 柱状图点击事件
drawlineCRK() { let _this = this; ///绘制echarts 柱状图 let mycharts = this.$echarts.i ...
- dfs+剪枝 poj1011
Sticks Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 113547 Accepted: 26078 问题描述 Ge ...
- bzoj2127happiness(最小割)
一眼最小割. 一种比较好想的建图方式如下: 连源点表示学文,连汇点表示学理,然后adde(S,id(i,j),a[i][j]),adde(id(i,j),T,b[i][j]):对于相邻座位选择同一科的 ...
- 论文或github中一些通用思想
(1) 云从 上海交大 ECCV2018 http://openaccess.thecvf.com/content_ECCV_2018/papers/Yao_Feng_Joint_3D_Face_EC ...
- 吴裕雄--天生自然 PYTHON3开发学习:数据库连接 - PyMySQL 驱动
import pymysql # 打开数据库连接 db = pymysql.connect("localhost","testuser","test1 ...
- mybatis 自定义类型转换器 (后台日期类型插入数据库)
后台日期类型插入数据库 有以下几种发法: 1 调用数据库 日期字符串转日期函数 str_to_date("日期","yyyy-MM-dd HH:mm:ss") ...
- 二十九、rsync+inotity实时监控同步工具
一.场景应用: 客户通过url访问资源(查询,下载等),并发量是非常高的,所以运用负载均衡分担web服务器的压力,在后端连接不同的 ...
- MySQL修改表的默认字符集和修改表字段的默认字符集
修改表的默认字符集: ALTER TABLE table_name DEFAULT CHARACTER SET character_name; 修改表字段的默认字符集: ALTER TABLE tab ...
- jQuery实现button按钮提交表单
在JSP页面中,通常使用button按钮提交表单数据,使用jQuery实现代码如下: <span style="font-family:Comic Sans MS;font-size: ...