Created
February 18, 2015 03:46
-
-
Save ik11235/72cafa895147f3898889 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
class TaroJiroDividing { | |
public: | |
int getNumber(int A, int B) { | |
set<int> hash; | |
hash.insert(A); | |
for(;A%2==0;) | |
{ | |
A/=2; | |
hash.insert(A); | |
} | |
int cnt=0; | |
if(hash.count(B)!=0) | |
cnt++; | |
for(;B%2==0;) | |
{ | |
B/=2; | |
if(hash.count(B)!=0) | |
cnt++; | |
} | |
return cnt; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment