Last active
October 16, 2023 09:07
-
-
Save FantasticJZI/41506217d3ce793ed05a74aaac0576ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
//判斷二進制的進位次數 | |
int carryTime(long int input) | |
{ | |
if(input%2==1) | |
return 0; | |
if(input%4==1) | |
return 1; | |
for(int i=31;i>=1;i--) | |
{ | |
if(input%(long int)pow(2,i)==0) | |
return i; | |
} | |
} | |
void main() | |
{ | |
long int N; | |
while(scanf("%ld",&N)!=EOF) | |
{ | |
if(N==0) | |
break; | |
else | |
printf("%d\n",carryTime(N+1)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment