ntuorangejuice / cheat-sheet

C++ Cheat Sheet for ACM ICPC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Save it

imdreamrunner opened this issue · comments

#include <bits/stdc++.h>

#define DEBUG true

#define GET_BIT(n, i) (((n) & (1 << ((i)-1))) >> ((i)-1)) // i start from 1
#define SET_BIT(n, i) ((n) | (1 << ((i)-1)))
#define CLR_BIT(n, i) ((n) & ~(1 << ((i)-1)))
#define SHOW_A(x) {if (DEBUG) cout << #x << " = " << x << endl;}
#define SHOW_B(x, y) {if (DEBUG) cout << #x << " = " << x << ", " << #y << " = " << y << endl;}
#define SHOW_C(x, y, z) {if (DEBUG) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;}
#define REACH_HERE {if (DEBUG) cout << "REACH_HERE! line: " << __LINE__ << endl;}

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int test = 0, pass = 0;

void _assert(bool result) {
    test++; pass+=result;
    cout << (result ? "PASS: " : "FAIL: ");
}


int main() {
    ios::sync_with_stdio(false);

    int x = 0;
    ASSERT(x==0)
    ASSERT((x = SET_BIT(x, 3))==4)
    ASSERT((x = CLR_BIT(x, 3))==0)

    cout << "Total test: " << test << endl;
    cout << "Passed: " << pass << " (" << 100.0*pass/test << "%%)" << endl;

    return 0;
}