### angelbeats's blog

By angelbeats, 2 months ago,
portable version

• +10

 » 2 months ago, # |   -7 Where did I go wrong in life ?
 » 2 months ago, # |   +8 What's the point?
•  » » 2 months ago, # ^ |   +3 Changing the code from REP(i, a) to FOR(i, 1, a) is annoying
 » 2 months ago, # |   +13 one loop for everything Code#define FOR(i, a, b, s) for(ll i = (a); i < (b); i += (s)) #define ROF(i, a, b, s) for(ll i = (a); i > (b); i += (s)) #define FOR1(b) FOR(_, 0, b, 1) #define FOR2(i, b) FOR(i, 0, b, 1) #define FOR3(i, a, b) FOR(i, a, b, 1) #define FOR4(i, a, b, s) FOR(i, a, b, s) #define ROF1(i, b) ROF(i, b, -1, -1) #define ROF2(i, a, b) ROF(i, a, b, -1) #define ROF3(i, a, b, s) ROF(i, a, b, s) #define GETC(a, b, c, d, e, ...) e #define FORC(...) GETC(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1) #define ROFC(...) GETC(__VA_ARGS__, ROF3, ROF2, ROF1) #define loop(...) FORC(__VA_ARGS__)(__VA_ARGS__) #define rloop(...) ROFC(__VA_ARGS__)(__VA_ARGS__) void solve(int &T) { loop(5) { cout << _ << " "; } cout << endl; loop(j, 5) { cout << j << " "; } cout << endl; loop(j, 5, 10) { cout << j << " "; } cout << endl; loop(j, 5, 10, 2) { cout << j << " "; } cout << endl; rloop(k, 5, -1) { cout << k << " "; } cout << endl; rloop(k, 10, -1, -3) { cout << k << " "; } cout << endl; loop(i, 10, 5) { assert(0); } rloop(i, 10, 10) { assert(0); } loop(i, 4, 10, 0) { cout << i << " "; i++; } cout << endl; rloop(i, 10, 4, 0) { cout << i << " "; i--; } cout << endl; rloop(i, 10) { cout << i << " "; } cout << endl; } 
•  » » 2 months ago, # ^ |   +2 Choosing macro based on argc is really clever. It's time to get rid of old templates.
•  » » » 2 months ago, # ^ |   0 copied from tmwilliamlin168 template :)
 » 2 months ago, # |   +27 Beware of side effects. rep(i, get_min(), get_max()) will call the functions several times.
 » 2 months ago, # |   +49 Solution