fork download
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3.  
  4. bool isPowerOfThree(int n) {
  5. return n > 0 && 1162261467 % n == 0; //利用int範圍內最大的power of three判斷
  6. }
  7.  
  8. int main(){
  9. int n;
  10. scanf("%d",&n);
  11. bool result=isPowerOfThree(n);
  12. (result==0)? printf("false"):printf("true");
  13. return 0;
  14. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
false