We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1f8b2cd commit 0858fb3Copy full SHA for 0858fb3
CuttingBitString.cpp
@@ -33,18 +33,12 @@ typedef long long ll;
33
#define fle(b) for(int l=0; l <= ((int)(b)); l++) // l -> [0, b]
34
35
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
- }
+
41
bool isPower(string s){
42
- int i = 0;
43
if(s[0] == '0') return false;
44
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);
+ while(a % 5 == 0) a = a/5;
+ return a == 1;
48
}
49
50
public:
0 commit comments