Skip to content

Instantly share code, notes, and snippets.

@hitripod
Last active December 14, 2021 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitripod/54dece738afea7d7cf88d576579cb625 to your computer and use it in GitHub Desktop.
Save hitripod/54dece738afea7d7cf88d576579cb625 to your computer and use it in GitHub Desktop.
Simple Quiz

進擊的韭菜

題目描述

幣圈裡面,有一種暱稱叫做 韭菜 的生物,如果你想要低價買入他們手上的比特幣,放出一些恐慌訊息,他們馬上就會賣掉;相反的,如果你想要高價賣出你手上的囤貨,你只要放出利好消息,他們就會蜂蛹買入。

輸入說明

  • 第一行有一個整數 N (N <= 999,999,999,999),代表有 n 個韭菜由左至右排成一排,這些韭菜手上都持有比特幣,由最左邊的韭菜開始編號: 1, 2, 3, ..., N。
  • 第二行有一整數 M (M <= 999999),接下來會有 M 次割韭菜的行為。
  • 接下來 M 行每行有兩個整數 [i, j]。表示對從 i 到 j 的這堆韭菜進行收割。

輸出說明

請輸出最後有多少韭菜還沒有賣掉比特幣?

範例輸入:

5 // N
3 // M
1 3 // [i, j] 
3 5 // [i, j]
1 5 // [i, j]

範例輸出:

4

答題要求

請將你的解答上傳到 Github,並且將解題思路與執行方式寫在 README.md 上。

答題形式不拘,程式語言不拘,歡迎自由發揮。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment