日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【CodeForces - 618A】Slime Combining(二进制,思维)

發(fā)布時間:2023/12/10 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【CodeForces - 618A】Slime Combining(二进制,思维) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

題干:

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?nslimes. 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.

Examples

Input

1

Output

1

Input

2

Output

2

Input

3

Output

2 1

Input

8

Output

4

Note

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
  • 2
  • 2 1
  • 3
  • 3 1
  • 3 2
  • 3 2 1
  • 4
  • 題目大意:

    朋友們送了一些史萊姆當作小N的生日禮物,總共有n個史萊姆,每個粘度為1。

    小N打算用這些史萊姆玩游戲。他開始時先在桌子上放置一個史萊姆,然后逐個添加其他n-1個史萊姆。?

    當添加史萊姆時,每次都將其放置在所有已放置的史萊姆的右側(cè)。 一旦出現(xiàn)兩個相鄰的史萊姆粘度相同均為v ,它們就將組合在一起變?yōu)橐粋€粘度v+1的史萊姆。

    小N想知道在添加所有n個史萊姆之后,桌子上所有史萊姆的粘度是多少。 請從左到右打印史萊姆的粘度。

    解題報告:

    ? ?不難發(fā)現(xiàn)規(guī)律是二進制中1的位置,然后亂搞就行了。

    AC代碼:

    #include<cstdio> #include<iostream> #include<algorithm> #include<queue> #include<map> #include<vector> #include<set> #include<string> #include<cmath> #include<cstring> #define ll long long #define pb push_back #define pm make_pair using namespace std; const int MAX = 200 + 5; int ans[MAX]; int tot; int main() {int n;cin>>n;int cur = 0;while(n) {cur++;if(n&1) ans[++tot] = cur;n>>=1;}for(int i = tot; i>=1; i--) {printf("%d ",ans[i]);}return 0 ; }

    ?

    總結(jié)

    以上是生活随笔為你收集整理的【CodeForces - 618A】Slime Combining(二进制,思维)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。