[topcoder]LongLongTripDiv2
http://community.topcoder.com/stat?c=problem_statement&pm=13091
解方程,对中国孩子太简单了。
#include <vector> #include <iostream> using namespace std; class LongLongTripDiv2 { public: string isAble(long long D, int T, int B) { long long diff = (D - T); if (diff % (B - 1) != 0) return "Impossible"; long long b = diff / (B - 1); long long a = T - b; if (b >= 0 && a >= 0) return "Possible"; return "Impossible"; } };