mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-07 01:23:57 -05:00
Updated to work with the new libraries
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//ProjectEuler/ProjectEulerCPP/headers/Problems/Problem33.hpp
|
||||
//Matthew Ellison
|
||||
// Created: 02-05-2021
|
||||
//Modified: 02-05-2021
|
||||
// Created: 02-05-21
|
||||
//Modified: 07-03-21
|
||||
/*
|
||||
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplify it may incorrectly believe that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s
|
||||
We shall consider fractions like, 30/50 = 3/5, to be trivial examples
|
||||
@@ -25,12 +25,10 @@ If the product of these four fractions is given in its lowest common terms, find
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PROBLEM33_HPP
|
||||
#define PROBLEM33_HPP
|
||||
|
||||
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "Problem.hpp"
|
||||
@@ -40,14 +38,14 @@ class Problem33: public Problem{
|
||||
private:
|
||||
//Variables
|
||||
//Static variables
|
||||
static int MIN_NUMERATOR; //The lowest the numerator can be
|
||||
static int MAX_NUMERATOR; //The highest the numerator can be
|
||||
static int MIN_NUMERATOR; //The lowest the numerator can be
|
||||
static int MAX_NUMERATOR; //The highest the numerator can be
|
||||
static int MIN_DENOMINATOR; //The lowest the denominator can be
|
||||
static int MAX_DENOMINATOR; //The highest the denominator can be
|
||||
//Instance variables
|
||||
std::vector<int> numerators; //Holds the numerators that were found
|
||||
std::vector<int> denominators; //Holds the denominators that were found
|
||||
int prodDenominator; //Holds the answer to the question
|
||||
int prodDenominator; //Holds the answer to the question
|
||||
public:
|
||||
//Constructor
|
||||
Problem33();
|
||||
@@ -55,15 +53,17 @@ public:
|
||||
virtual void solve(); //Solve the problem
|
||||
virtual void reset(); //Reset the problem so it can be run again
|
||||
//Gets
|
||||
virtual std::string getResult(); //Return a string with the solution to the problem
|
||||
std::vector<int> getNumerators(); //Returns the list of numerators
|
||||
std::vector<int> getDenominators(); //Returns the list of denominators
|
||||
int getProdDenominator(); //Returns the answer to the question
|
||||
virtual std::string getResult() const; //Return a string with the solution to the problem
|
||||
std::vector<int> getNumerators() const; //Returns the list of numerators
|
||||
std::vector<int> getDenominators() const; //Returns the list of denominators
|
||||
int getProdDenominator() const; //Returns the answer to the question
|
||||
};
|
||||
|
||||
|
||||
/* Results:
|
||||
The denominator of the product is 100
|
||||
It took an average of 69.741 microseconds to run this problem over 100 iterations
|
||||
*/
|
||||
|
||||
#endif //PROBLEM33_HPP
|
||||
|
||||
#endif //PROBLEM33_HPP
|
||||
|
||||
Reference in New Issue
Block a user