Created
June 6, 2018 01:01
-
-
Save Jerror/9d5d9a5b1c0cf4e78adc563d0088a5bf to your computer and use it in GitHub Desktop.
Revisions
-
Jerror created this gist
Jun 6, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ #include <cstring> #include <optional> using namespace std; const int A = 4; const int B = 6; const int CD = 8; const int E = 6; optional<int> fa(int a) { if (a >= A) { return a/2; } else { return nullopt; } } optional<int> fb(int b) { if (b >= B) { return b/3; } else { return nullopt; } } optional<int> fcd(int c, int d) { if (c*d >= CD) { return c*d/2; } else { return nullopt; } } optional<int> fe(int e) { if (e >= E) { return e; } else { return nullopt; } } int main(int argc, char *argv[]) { int a = atoi(argv[1]); int b = atoi(argv[2]); if (optional<int> tmp, x; (tmp = fa(a)) && (x = fb(b)) && (x = fcd(*tmp, *x)) && (x = fe(*x))) { return *x; } else { return 0; } }