A. Slime Combining

题目连接:

http://www.lydsy.com/JudgeOnline/problem.php?id=2768

Description

Your friend recently gave you some slimes for your birthday. You have n slimes all initially with value 1.

You are going to play a game with these slimes. Initially, you put a single slime by itself in a row. Then, you will add the other n - 1 slimes one by one. When you add a slime, you place it at the right of all already placed slimes. Then, while the last two slimes in the row have the same value v, you combine them together to create a slime with value v + 1.

You would like to see what the final state of the row is after you've added all n slimes. Please print the values of the slimes in the row from left to right.

Input

The first line of the input will contain a single integer, n (1 ≤ n ≤ 100 000).

Output

Output a single line with k integers, where k is the number of slimes in the row after you've finished the procedure described in the problem statement. The i-th of these numbers should be the value of the i-th slime from the left.

Sample Input

1

Sample Output

1

Hint

题意

有n个数字,依次放进栈内,然后遇到相同的数,就合并成为v+1

然后问你最后剩下的数字是哪些

题解:

直接暴力模拟就好了

代码

#include<bits/stdc++.h>
using namespace std; stack<int> S;
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int now = 1;
while(S.size()!=0)
{
int next = S.top();
if(next==now)
{
S.pop();
now = now+1;
}
else
break;
}
S.push(now);
}
vector<int> ans;
while(S.size())
{
ans.push_back(S.top());
S.pop();
}
for(int i=ans.size()-1;i>=0;i--)
printf("%d ",ans[i]);
}

Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) A. Slime Combining 水题的更多相关文章

  1. Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) B. Guess the Permutation 水题

    B. Guess the Permutation 题目连接: http://www.codeforces.com/contest/618/problem/B Description Bob has a ...

  2. Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) F. Double Knapsack 鸽巢原理 构造

    F. Double Knapsack 题目连接: http://www.codeforces.com/contest/618/problem/F Description You are given t ...

  3. Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) E. Robot Arm 线段树

    E. Robot Arm 题目连接: http://www.codeforces.com/contest/618/problem/E Description Roger is a robot. He ...

  4. Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)

    现在水平真的不够.只能够做做水题 A. Slime Combining 题意:就是给n个1给你.两个相同的数可以合并成一个数,比如说有两个相同的v,合并后的值就是v+1 思路:直接模拟栈 #inclu ...

  5. Codeforces Round #348 (VK Cup 2016 Round 2, Div. 2 Edition) A. Little Artem and Presents 水题

    A. Little Artem and Presents 题目连接: http://www.codeforces.com/contest/669/problem/A Description Littl ...

  6. VK Cup 2016 - Round 1 (Div. 2 Edition) A. Bear and Reverse Radewoosh 水题

    A. Bear and Reverse Radewoosh 题目连接: http://www.codeforces.com/contest/658/problem/A Description Lima ...

  7. Codeforces Round #385 (Div. 2) A. Hongcow Learns the Cyclic Shift 水题

    A. Hongcow Learns the Cyclic Shift 题目连接: http://codeforces.com/contest/745/problem/A Description Hon ...

  8. Codeforces Round #356 (Div. 2)B. Bear and Finding Criminals(水题)

    B. Bear and Finding Criminals time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  9. Codeforces Round #397 by Kaspersky Lab and Barcelona Bootcamp (Div. 1 + Div. 2 combined) B. Code obfuscation 水题

    B. Code obfuscation 题目连接: http://codeforces.com/contest/765/problem/B Description Kostya likes Codef ...

随机推荐

  1. Drupal 7.23:函数drupal_alter()注释

    /** * Passes alterable variables to specific hook_TYPE_alter() implementations. * * This dispatch fu ...

  2. 经典非原创,网页常用Javascript

    网页常用Javascript 1.让文字不停地滚动 <MARQUEE>滚动文字</MARQUEE> 2.记录并显示网页的最后修改时间 <script language=J ...

  3. C.xml

    pre{ line-height:1; color:#1e1e1e; background-color:#f0f0f0; font-size:16px;}.sysFunc{color:#627cf6; ...

  4. nagios监控远程主机端口

    1 被监控主机上的操作 修改nrpe插件内容: 在其中增加的内容如下: 表示的含义为监控主机的端口631和661,这个主要是监控命令 重启xinetd服务: 2 监控主机上的操作 查看监控命令配置文件 ...

  5. 【Python学习笔记】字典操作

    字典dict是Python中唯一内置的映射类型,由键值对组成,字典是无序的.字典的键必须是不变对象,如字符串.数字.元组等,而包含可变对象的列表.字典和元组则不能作为键.这里可变和不可变的意思是指这个 ...

  6. WebGIS的大众化服务

    WebGIS是Web技术与GIS相结合的产物.WebGIS的真正意义在于,它将GIS从专业应用推向了大众化服务,同时为地理信息共享提供了方便而有效的途径. 一.ESRI大会关于WebGIS的报告 纵观 ...

  7. C#获取文件的绝对路径

    要在c#中获取路径有好多方法,一般常用的有以下五种: //获取应用程序的当前工作目录. String path1 = System.IO.Directory.GetCurrentDirectory() ...

  8. 第三百五十三天 how can I 坚持

    今天买了床被子,凑合盖吧,也不是多好. 下午去了趟华北电力大学,和刘路聊了聊,还是话太多了..不好. 还有买了桶油和大米.. 洗澡,睡觉,一天过得好快.

  9. 开着奥迪做Uber司机是什么心态?

    滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...

  10. Java之对象池

    单例模式是限制了一个类只能有一个实例,对象池模式则是限制一个类实例的个数.对象池类就像是一个对象管理员,它以Static列表(也就是装对象的池子)的形式存存储某个实例数受限的类的实例,每一个实例还要加 ...