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. 1
Output
  1. 1
Input
  1. 2
Output
  1. 2
Input
  1. 3
Output
  1. 2 1
Input
  1. 8
Output
  1. 4

Sample Output

  1. Case #1:
  2. 17
  3. Case #2:
  4. 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

  1. #include<cstdio>
  2. #include<cmath>
  3. #include<cstring>
  4. #include<iostream>
  5. #include<algorithm>
  6. using namespace std;
  7. int main()
  8. {
  9. __int64 n;
  10. while(scanf("%I64d",&n)!=EOF)
  11. {
  12. int num[1010],cnt=0;
  13. memset(num,0,sizeof(num));
  14. while(n)
  15. {
  16. for(int i=0;;i++)
  17. {
  18. int ans=pow(2,i);
  19. if(pow(2,i+1)>n&&ans<=n)
  20. {
  21. num[cnt++]=i+1;
  22. n-=pow(2,i);
  23. break;
  24. }
  25. }
  26. }
  27. for(int i=0;i<cnt-1;i++)
  28. printf("%d ",num[i]);
  29. printf("%d\n",num[cnt-1]);
  30. }
  31. return 0;
  32. }

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. laydate.js 月份区间选择插件

    laydate.render({ elem: '#reservation2' , type: 'month' , range: true, //format: '2018/09', theme: '# ...

  2. Mybatis逆向工程使用方法

    使用官方网站的mapper自动生成工具mybatis-generator-core-1.3.2来生成po类和mapper映射文件. 一.mapper生成配置文件 在generatorConfig.xm ...

  3. 使用cloudcompare进行对比轨迹及评价

    0.预备知识: 我的系统是Ubuntu 16.04. 在其他发行版中,可能需要先安装snap(如有必要,请参阅相应的文档).快照发布在3个频道:“稳定”,“测试版”和“边缘”.“稳定版”和“测试版”频 ...

  4. 51nod 1050 循环数组最大子段和【动态规划】

    N个整数组成的循环序列a[1],a[2],a[3],-,a[n],求该序列如a[i]+a[i+1]+-+a[j]的连续的子段和的最大值(循环序列是指n个数围成一个圈,因此需要考虑a[n-1],a[n] ...

  5. [luogu3067 USACO12OPEN] 平衡的奶牛群

    传送门 Solution 折半搜索模板题 考虑枚举每个点在左集合和右集合或者不在集合中,然后排序合并即可 Code //By Menteur_Hxy #include <cmath> #i ...

  6. 洛谷 2866 [USACO06NOV]糟糕的一天Bad Hair Day

    [题意概述] 给出一个长度为n的序列a,求有多少对[i,j]满足i<j且a[i]>max(a[i+1],a[i+2],...,a[j]). [题解] 单调栈. 倒着处理序列的元素,维护一个 ...

  7. FJoi2017 1月21日模拟赛 comparison(平衡树+thita重构)

    题目大意: 经黄学长指出,此题原题出自2014湖北省队互测 没有人的算术 规定集合由二元组(A,B)构成,A.B同时也是两个这样的集合,即A.B本身也是二元组 规定二元组S为严格最小集合,S=(S,S ...

  8. java 使用OpenOffice文件实现预览

    1.安装OpenOffice软件 安装教程:https://jingyan.baidu.com/article/c275f6ba12c07ce33d756732.html 2.安装完成后,创建项目,p ...

  9. POJ3624 0-1背包(dp+滚动数组)

    Charm Bracelet Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 47440   Accepted: 20178 ...

  10. 利用tempalte.js模版引擎渲染页面,作对应的数据处理

    需要启个服务 需引入jquery.js和template.js <!DOCTYPE html> <html lang="en"> <head> ...