Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int bintodec(string &s)
- {
- int num = 0;
- //32 bit;;
- //0 ---------31
- //0----------30
- for (int i = 0; i < s.length(); i++) {
- num += (1LL << i) * (s[i] - '0');
- }
- return num;
- }
- bool powoftwo(int &num) {
- int count = 0;
- for (int i = 0; i <= 30; i++)
- {
- if ((num & (1LL << i))) count++;
- }
- if (count <= 1) return true;
- return false;
- }
- void printbinary(int &x)
- {
- //32 bit representable number
- for (int i = 0; i < 31; i++)
- {
- if ((1LL << i)&x) cout << 1;
- else cout << 0;
- }
- cout << endl;
- }
- int main()
- {
- // string s; cin >> s;
- // //binary string
- // int num = bintodec(s);
- // cout << num << endl;
- // int num; cin >> num;
- // if (powoftwo(num)) {
- // cout << "YES" << endl;
- // }
- // else cout << "NO" << endl;
- // int x; cin >> x;
- // printbinary(x);
- /////////////////property 1
- // int a = 5, b = 18;
- // int c = (a ^ b);
- // cout << "a^b==c" << " " << (a ^ b) << endl;
- // cout << "c^b==a" << " " << (c ^ b) << endl;
- // cout << "c^a==b" << " " << (c ^ a) << endl;
- ///////////property 2
- cout << (5 ^ 5 ^ 5 ^ 5) << endl;
- cout << (5 ^ 5 ^ 5) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement