题解:
- 10进制数能否转换成3进制
class Solution {
public boolean checkPowersOfThree(int n) {
int[] a = new int[20];
a[0] = 1;
for (int i = 1; i < 20; i++) {
a[i] = a[i - 1] * 3;
}
for (int i = 19; i >= 0; i--) {
if (n >= a[i]) n -= a[i];
}
return n == 0;
}
}
标签:20,数字,1780,int,成三,进制
From: https://www.cnblogs.com/eiffelzero/p/16968120.html