Slime CombiningCrawling in process...

Crawling failed
Time Limit:2000MS    
Memory Limit:262144KB    
64bit IO Format:
%I64d & %I64u

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

Input
1
Output
1
Input
2
Output
2
Input
3
Output
2 1
Input
8
Output
4

Sample Output

Case #1:
17
Case #2:
4
 

Hint

In the first sample, we only have a single slime with value
1. The final state of the board is just a single slime with value
1.

In the second sample, we perform the following steps:

Initially we place a single slime in a row by itself. Thus, row is initially
1.

Then, we will add another slime. The row is now
1 1. Since two rightmost slimes have the same values, we should replace these slimes with one with value
2. Thus, the final state of the board is
2.

In the third sample, after adding the first two slimes, our row is
2. After adding one more slime, the row becomes
2 1.

In the last sample, the steps look as follows:

  1. 1
  2. 2
  3. 2 1
  4. 3
  5. 3 1
  6. 3 2
  7. 3 2 1
  8. 4

#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
__int64 n;
while(scanf("%I64d",&n)!=EOF)
{
int num[1010],cnt=0;
memset(num,0,sizeof(num));
while(n)
{
for(int i=0;;i++)
{
int ans=pow(2,i);
if(pow(2,i+1)>n&&ans<=n)
{
num[cnt++]=i+1;
n-=pow(2,i);
break;
}
}
}
for(int i=0;i<cnt-1;i++)
printf("%d ",num[i]);
printf("%d\n",num[cnt-1]);
}
return 0;
}

Codeforces--618A--Slime CombiningCrawling(数学)的更多相关文章

  1. CodeForces 618A Slime Combining

    http://www.codeforces.com/contest/618/problem/A 明明觉得是水题,而我却做了一个小时. 明明觉得代码没有错,而我却错了好几次. 因为我的名字不叫明明,也不 ...

  2. CodeForces 534C Polycarpus' Dice (数学)

    题意:第一行给两个数,n 和 A,n 表示有n 个骰子,A表示 n 个骰子掷出的数的和.第二行给出n个数,表示第n个骰子所能掷出的最大的数,这些骰子都有问题, 可能或多或少的掷不出几个数,输出n个骰子 ...

  3. codeforces 687B - Remainders Game 数学相关(互质中国剩余定理)

    题意:给你x%ci=bi(x未知),是否能确定x%k的值(k已知) ——数学相关知识: 首先:我们知道一些事情,对于k,假设有ci%k==0,那么一定能确定x%k的值,比如k=5和ci=20,知道x% ...

  4. Codeforces 1038D - Slime - [思维题][DP]

    题目链接:http://codeforces.com/problemset/problem/1038/D 题意: 给出 $n$ 个史莱姆,每个史莱姆有一个价值 $a[i]$,一个史莱姆可以吃掉相邻的史 ...

  5. Codeforces Gym 100269G Garage 数学

    Garage 题目连接: http://codeforces.com/gym/100269/attachments Description Wow! What a lucky day! Your co ...

  6. Codeforces C. Almost Equal (数学规律)

    题目链接:http://codeforces.com/contest/1206/problem/C 题解 : 观察可以发现当n为偶数时,1 - 2n是不满足题意的,可以举例n = 2,n = 4试一试 ...

  7. codeforces 101C C. Vectors(数学)

    题目链接: C. Vectors time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  8. Educational Codeforces Round 15 D 数学推公式

    D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...

  9. CodeForces 589D Boulevard (数学,相遇)

    题意:给定 n 个的在 x 轴上的坐标,和开始时间,结束坐标,从起点向终点走,如果和其他人相遇,就互相打招乎,问你每人打招乎的次数. 析:其实这一个数学题,由于 n 比较小,我们就可以两两暴力,这两个 ...

  10. Codeforces 311D Interval Cubing 数学 + 线段树 (看题解)

    Interval Cubing 这种数学题谁顶得住啊. 因为 (3 ^ 48) % (mod - 1)为 1 , 所以48个一个循环节, 用线段树直接维护. #include<bits/stdc ...

随机推荐

  1. 巩固JavaSE基础--IDEA完成实战项目

    PS:学习完JavaSE基础后,需要有一个项目来测试自己的学习成果,并加以巩固.所以在这里,就让我们来学习下“一本糊涂账”项目吧.(此项目来源于Java自学网站) 项目完成效果图一览

  2. 40条常见的移动端Web页面问题解决方案

    1.安卓浏览器看背景图片,有些设备会模糊.想让图片在手机里显示更为清晰,必须使用2x的背景图来代替img标签(一般情况都是用2倍).例如一个div的宽高是100100,背景图必须得200200,然后b ...

  3. eclipse 中常用快捷键

    * 字母大小写转换 ctrl+shift+x   转为大写 ctrl+shift+y   转为小写 * eclipse 自动生成对象来接收方法的返回值的快捷键 说明:光标一定要定位到要自动生成返回值对 ...

  4. 爬虫之Selenium库

    官方文档:https://selenium-python.readthedocs.io/ Selenium:自动化测试工具,支持多种浏览器.爬虫中主要用来解决JavaScript渲染的问题. 一.开始 ...

  5. pandas处理各类表格数据

    经常遇到Python读取excel和csv还有其他各种文件的内容.json还有web端的读取还是比较简单,但是excel和csv的读写是很麻烦.这里记录了pandas库提供的方法来实现文本内容和Dat ...

  6. springcloud(十一):熔断聚合监控Hystrix Turbine

    springcloud(十一):熔断聚合监控Hystrix Turbine

  7. 使用pycharm学习django纪实

    之前已经下了python3.7 首先官网下载pycharm专业版,然后利用学生邮箱激活 新建django项目,使用虚拟环境就好了,方便之后的服务器部署(大概 找到博客开始学习:https://blog ...

  8. 我安装android studio的过程与经历

    虽然android studio已经出来两年多了,但是我一直都没真正用过.之前用Eclipse还算用得挺好.我并不是一个专职的android开发者,我是个游戏开发者,打包的时候要用到android.不 ...

  9. HTTP 请求的 GET 与 POST 方式的区别

    HTTP 请求的 GET 与 POST 方式的区别 在客户机和服务器之间进行请求-响应时,两种最常被用到的方法是:GET 和 POST. GET - 从指定的资源请求数据. POST - 向指定的资源 ...

  10. Leetcode 89.格雷编码

    格雷编码 格雷编码是一个二进制数字系统,在该系统中,两个连续的数值仅有一个位数的差异. 给定一个代表编码总位数的非负整数 n,打印其格雷编码序列.格雷编码序列必须以 0 开头. 示例 1: 输入: 2 ...