五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(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的評論 (共 條)

分享到微博請遵守國家法律
锡林郭勒盟| 肥乡县| 兴隆县| 江西省| 台北市| 临朐县| 闸北区| 女性| 炎陵县| 泰和县| 徐汇区| 四平市| 石家庄市| 从江县| 获嘉县| 沁水县| 广河县| 岳阳市| 安图县| 北川| 新建县| 囊谦县| 鄱阳县| 桃源县| 翼城县| 得荣县| 泗阳县| 昭觉县| 涞水县| 洛宁县| 朝阳县| 沙坪坝区| 湘潭县| 南华县| 乌拉特前旗| 四会市| 太白县| 成安县| 古浪县| 苏尼特左旗| 青田县|