0326.cpp (148B)
1 class Solution { 2 public: 3 bool isPowerOfThree(int n) { 4 double x = log10(n) / log10(3); 5 return n > 0 && x == round(x); 6 } 7 };