资讯中心

leetcode 耗时100 1780. Check if Number is a Sum of Powers of Three

📅 2026/9/20 6:45:06
leetcode 耗时100 1780. Check if Number is a Sum of Powers of Three
Problem: 1780. 判断一个数字是否可以表示成三的幂的和耗时100%转三进制数字看三进制数字里面是否存在1的数字即可Codeclass Solution { public: bool checkPowersOfThree(int n) { vectorint tr; int t; while(n 0) { t n % 3; n n / 3; tr.push_back(t); } for(int i : tr) { if(i 1) return false; } return true; } };

看完文章,想为自己的企业也做一次专业网站诊断?

尧图顾问免费为您评估现有网站,并给出建站/改版建议与报价方案。

免费获取方案