国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

CF344A - Magnets

2023-06-24 09:25 作者:您是打尖兒還是住店呢  | 我要投稿

Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the opposite poles will attract each other.


Mike starts by laying one magnet horizontally on the table. During each following step Mike adds one more magnet horizontally to the right end of the row. Depending on how Mike puts the magnet on the table, it is either attracted to the previous one (forming a group of multiple magnets linked together) or repelled by it (then Mike lays this magnet at some distance to the right from the previous one). We assume that a sole magnet not linked to others forms a group of its own.Mike arranged multiple magnets in a row. Determine the number of groups that the magnets formed.


Input The first line of the input contains an integer n (1?≤?n?≤?100000) — the number of magnets. Then n lines follow. The i-th line (1?≤?i?≤?n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.

------------------------------------------------------------

中文:

瘋狂科學(xué)家邁克通過排列多米諾骨牌來娛樂自己。 不過,他不需要多米諾骨牌:他使用矩形磁鐵。 每個磁鐵都有兩個極,正極(“正”)和負(fù)極(“減”)。 如果兩個磁鐵靠近放置在一起,那么同極會相互排斥,異極會相互吸引。


邁克首先將一塊磁鐵水平放在桌子上。 在接下來的每個步驟中,邁克都會在該行的右端水平添加一個磁鐵。 根據(jù)邁克將磁鐵放在桌子上的方式,它要么被前一個磁鐵吸引(形成一組連接在一起的多個磁鐵),要么被它排斥(然后邁克將這塊磁鐵放置在距前一個磁鐵右側(cè)一定距離的地方) 。 我們假設(shè)沒有與其他磁鐵相連的單個磁鐵形成了自己的一組。邁克將多個磁鐵排成一排。 確定磁鐵形成的組數(shù)。


輸入 輸入的第一行包含一個整數(shù) n (1?≤?n?≤?100000) — 磁鐵的數(shù)量。 然后是n行。 第 i 行 (1?≤?i?≤?n) 包含字符“01”(如果 Mike 將第 i 個磁鐵放在“正負(fù)”位置)或字符“10”(如果 Mike 將磁鐵放在“ 減-加”位置。

--------------------------------------

其實就是計算11或者00出線的次數(shù),出線多少次,那么就分成n+1次。輸出即可;

下面是代碼:


CF344A - Magnets的評論 (共 條)

分享到微博請遵守國家法律
叙永县| 石景山区| 新巴尔虎右旗| 儋州市| 苍梧县| 株洲市| 虞城县| 云和县| 铜陵市| 库尔勒市| 商洛市| 罗田县| 静安区| 出国| 清远市| 如皋市| 湖南省| 秭归县| 景谷| 黄大仙区| 汉中市| 鹤岗市| 洪雅县| 霍州市| 夏邑县| 长白| 长丰县| 交城县| 汽车| 丰镇市| 东明县| 八宿县| 绍兴市| 六盘水市| 察隅县| 句容市| 昌图县| 巴彦淖尔市| 富川| 杂多县| 历史|