Title / Description
Code #include <iostream> #include <algorithm> using namespace std; class xlong { public: int p[100], h; xlong() { h = 1; p[0] = 0; } /* fff */ xlong(int n) { h = 1; p[0] = n; } xlong operator +(xlong x) { xlong res(0); int m = 0; for (int i = 0; i < 100; i++) { m = (i < h ? p[i] : 0) + (i < x.h ? x.p[i] : 0) + m; res.p[i] = m % 10; m /= 10; } res.h = 99; for (int i = 99; i > 0 && res.p[i] == 0; i--) res.h = i; return res; } }; ostream& operator << (ostream& out, xlong x) { for (int i = x.h - 1; i >= 0; i--) cout << x.p[i]; return out; } int main() { long long n, t, k; cin >> n >> t >> k; long long p[t]; xlong d[t]; for (int i = 0; i < t; i++) cin >> p[i]; sort(p, p + t); for (int i = 0; i < t; i++) { d[i] = 0; if (p[i] <= k) d[i] = 1; for (int j = 0; j < i; j++) if (p[i] - p[j] <= k) d[i] = d[i] + d[j]; if (p[i] == n) { cout << d[i]; return 0; } } cout << 0; return 0; }
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code