小编Alg*_*eek的帖子

减少时间复杂性

int main()
{
   int n ;
   std::cin >> n; // or scanf ("%d", &n);
   int temp;
   if( n ==1 ) temp = 1; // if n is 1 number is power of 2 so temp = 1
   if( n % 2 != 0 && n!= 1) temp =0; // if n is odd it can't be power of two
   else
   {
       for (;n && n%2 == 0; n /= 2);
       if(n  > 0 && n!= 1) temp = 0; // …
Run Code Online (Sandbox Code Playgroud)

c c++ algorithm time-complexity

2
推荐指数
1
解决办法
2144
查看次数

标签 统计

algorithm ×1

c ×1

c++ ×1

time-complexity ×1