Skip to content

Commit 0858fb3

Browse files
committed
srm 555 div 1 250 sol
1 parent 1f8b2cd commit 0858fb3

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

CuttingBitString.cpp

+3-9
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,12 @@ typedef long long ll;
3333
#define fle(b) for(int l=0; l <= ((int)(b)); l++) // l -> [0, b]
3434

3535
class CuttingBitString{
36-
bool isPower(ll s){
37-
if(s == 1) return true;
38-
if(s == 0) return false;
39-
return s%5 == 0 && isPower(s/5);
40-
}
36+
4137
bool isPower(string s){
42-
int i = 0;
4338
if(s[0] == '0') return false;
4439
ll a = stoll(s, NULL, 2);
45-
if(a == 1) return true;
46-
if(a == 0) return false;
47-
return a%5 == 0 && isPower(a/5);
40+
while(a % 5 == 0) a = a/5;
41+
return a == 1;
4842
}
4943

5044
public:

0 commit comments

Comments
 (0)