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. Java中的OutOfMemoryError的各种情况及解决和JVM内存结构

    在JVM中内存一共有3种:Heap(堆内存),Non-Heap(非堆内存) [3]和Native(本地内存). [1] 堆内存是运行时分配所有类实例和数组的一块内存区域.非堆内存包含方法区和JVM内部 ...

  2. Drupal配置文件settings.php搜索规则

    Drupal的配置文件搜索是通过bootstrap.inc的conf_path()函数实现的: function conf_path($require_settings = TRUE, $reset ...

  3. Nodejs_day03

    1.Stream (流) Stream有四种流类型 1.Readable - 可读操作 2.Writable - 可写操作 3.Duplex - 可读可写操作 4.Transform - 操作被写入数 ...

  4. Nodejs_day01

    helloworld.txt的内容: 我是nodejs 阻塞式调用 var fs = require('fs'); var data = fs.readFileSync('helloworld.txt ...

  5. 推荐一款C#反编译软件(开源)

    大二的时候老师要求做过一个小项目,大概4个人左右一组.当时交流不是特别到位,项目在一个同学的电脑上建成了就一直在他的电脑上(所以好东西不要烂在你的硬盘里),也不知道什么源码管理,可悲到项目做完我还没有 ...

  6. Linux 权限相关

    Linux中,所有文件都有 三种权限:User ,Group,Other 三个文件: /etc/passwd :包括所有系统账号,一般用户身份和root信息 /etc/shadow :保存个人密码 / ...

  7. Excel的 OleDb 连接串的格式

    Excel的 OleDb 连接串的格式(Provider=Microsoft.ACE.OLEDB)(2012-08-02 13:04:20) string strCon = "Provide ...

  8. (转载)OC学习篇之---类的延展

    前一篇文章我们介绍了类的类目概念和使用,那么这篇文章我们继续来介绍一下OC中的一个特性:延展. 其实说白了,延展就是弥补C语言中的前向申明,我们知道,在C语言中,如果你想调用一个函数的话,那么在此之前 ...

  9. FILETIME, SYSTEMTIME 与 time_t 相互转换

    FILETIME, SYSTEMTIME 与 time_t 相互转换 2009-08-24 15:37:14|  分类: 默认分类|举报|字号 订阅     //******************* ...

  10. stardict

    1.下载词典文件: 2.把下载到的文件移动到/tmp目录下 # mv stardict-*.bz2 /tmp 3.解压缩 # tar jxf stardict-oxford-gb-2.4.2.tar. ...