- In dynamic Programming all the subproblems are solved even those which are not needed, but in recursion only required subproblem are solved
- again, doing 458 uva - i type #nclude <string> instead of <string.h> - and it gives me WA! BE VERY CAREFUL WITH THIS
- when I solved "Hashmat the brave warrior" i used <cmath> to use abs() - it did not work, i included <algorithm> - and it worked! why? C++ 4.5.3 works in uva - it may be diff. from C++ 4.5.9 / 5.3.3 - YOU MUST KNOW WHAT FUNCTION BELONGS TO WHAT HEADER!
- when reading numbers - use chars; chars = integers: '5' - 65 and it will convert it to integer; no need to convert from string!
- I get frustrated when i see "WRONG ANSWER!" - no guys, just know that sometime it is "presentation error" ! , for example: print " answer" is not same as "Answer " / "answer " - it is all about spaces -
NOTHING WRONG WITH THE WORKING OF PROGRAM! IT IS JUST PRINTING THE RESULTS!
when reading in numbers use :
while( scanf ( "%d %d %d ", &n1, &n2, &n3 ) ){..................}
while( cin >> n1 >> n2 >> n3 ) ) {...............}
if you must have only 2 numbers in each line:
while(scanf("%lf%lf",&n,&p)==2){ ..............}
========================================================
below is very interesting way to cut C++ :
#define FOR(i,n) for(int i = 0;i<n;i++)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define READ freopen("input.txt", "r", stdin)
#define WRITE freopen("output.txt", "w", stdout)
#define LL long long
================================================
ANOTHER SUPER HANDY:!!!
// Input macros
#define s(n) scanf("%d",&n)
#define sc(n) scanf("%c",&n)
#define sl(n) scanf("%lld",&n)
#define sf(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
// Useful constants
#define INF (int)1e9
#define EPS 1e-9
// Useful hardware instructions
#define bitcount __builtin_popcount
#define gcd __gcd
// Useful container manipulation / traversal macros
#define forall(i,a,b) for(int i=a;i<b;i++)
#define foreach(v, c) for( typeof( (c).begin()) v = (c).begin(); v != (c).end(); ++v)
#define all(a) a.begin(), a.end()
#define in(a,b) ( (b).find(a) != (b).end())
#define pb push_back
#define fill(a,v) memset(a, v, sizeof a)
#define sz(a) ((int)(a.size()))
#define mp make_pair
// Some common useful functions
#define maX(a,b) ( (a) > (b) ? (a) : (b))
#define miN(a,b) ( (a) < (b) ? (a) : (b))
#define checkbit(n,b) ( (n >> b) & 1)
#define DREP(a) sort(all(a)); a.erase(unique(all(a)),a.end())
#define INDEX(arr,ind) (lower_bound(all(arr),ind)-arr.begin())
===========================================
DEBUGGER!
#ifdef DEBUG
#define debug(args...) {dbg,args; cerr<<endl;}
#else
#define debug(args...) // Just strip off all debug tokens
#endif
struct debugger
{
template<typename T> debugger& operator , (const T& v)
{
cerr<<v<<" ";
return *this;
}
} dbg;