class CQueue {
public:
stack<int> a;
stack<int> b;
CQueue() {
}
void appendTail(int value) {
a.push(value);
}
int deleteHead() {
int v = -1;
if (b.size() >0) {
v = b.top();
b.pop();
}
else{
while (!a.empty()) {
b.push(a.top());
a.pop();
}
if (!b.empty()) {
v = b.top();
b.pop();
}
}
return v;
}
};
/**
* Your CQueue object will be instantiated and called as such:
* CQueue* obj = new CQueue();
* obj->appendTail(value);
* int param_2 = obj->deleteHead();
*/
class Solution {
public:
int sumNums(int n) {
n && (n += sumNums(n-1));
return n;
}
};
class Solution {
public:
bool isPowerOfTwo(int n) {
int sum=0;
if(n<0)return false;
while(n!=0){
sum+=(n&1);
n=n>>1;
}
if(sum==1) return true;
else return false;
}
};
class Solution {
public:
bool isPowerOfThree(int n) {
return n > 0 && 1162261467%n ==0;
}
};
class Solution {
public:
bool isPowerOfFour(int n) {
if(n <= 0)
return false;
int num = log(n)/log(4);
return num*log(4) == log(n);
}
};