記n為數(shù)字位數(shù),
則下圖所示為O(n^2) 寫法
事實(shí)上,若 n>1e5 ,我們可以通過樹狀數(shù)組或線段樹優(yōu)化14~16行的循環(huán),將時(shí)間復(fù)雜度壓到 O(nlogn)