conchincradle / leetcode

0 stars 0 forks source link

05.数学 #11

Open conchincradle opened 2 years ago

conchincradle commented 2 years ago

数学

conchincradle commented 2 years ago

Java Math.pow(), is double

for integer, maybe (int )

and for 2^n

we can use 1<<n; represent 2^n

conchincradle commented 2 years ago

(int )Math.pow(10,3)

12. 整数转罗马数字

ones, tens, hundreds num/1000, (num%1000)/100,(num%100)/10,num%10 分别是千位百位十位个位的数字

conchincradle commented 2 years ago

int incre = hashmap.get(curr)<hashmap.get(right)?-hashmap.get(curr):hashmap.get(curr); sum += incre;

不能使用 sum = sum + 三元不等式,会默认直接复制给左边的sum,而不是加上sum之后再赋值!!!!