mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-07 01:23:57 -05:00
Updated comments and made sure style was consistent
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
//ProjectEuler/C++/Headers/Problem29.hpp
|
||||
//ProjectEuler/ProjectEulerCPP/Headers/Problem29.hpp
|
||||
//Matthew Ellison
|
||||
// Created: 10-06-19
|
||||
//Modified: 10-06-19
|
||||
//Modified: 07-09-20
|
||||
//How many distinct terms are in the sequence generated by a^b for 2 <= a <= 100 and 2 <= b <= 100?
|
||||
//Unless otherwise listed all non-standard includes are my own creation and available from https://bibucket.org/Mattrixwv/myClasses
|
||||
//This file contains a header from the gmp library. The library is used for large integers.
|
||||
//You can find more information about them at https://gmplib.org/
|
||||
//When compiling this file you need to have the gmp library installed as well as linking the libraries to your executable using the -lgmpxx and -lgmp flags
|
||||
/*
|
||||
Copyright (C) 2019 Matthew Ellison
|
||||
Copyright (C) 2020 Matthew Ellison
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
@@ -38,26 +38,32 @@
|
||||
|
||||
class Problem29 : public Problem{
|
||||
private:
|
||||
static const unsigned int BOTTOM_A = 2; //The lowest possible value for a
|
||||
static const unsigned int TOP_A = 100; //The highest possible value for a
|
||||
static const unsigned int BOTTOM_B = 2; //The lowest possible value for b
|
||||
static const unsigned int TOP_B = 100; //The highest possible value for b
|
||||
//Variables
|
||||
//Static variables
|
||||
static unsigned int BOTTOM_A; //The lowest possible value for a
|
||||
static unsigned int TOP_A; //The highest possible value for a
|
||||
static unsigned int BOTTOM_B; //The lowest possible value for b
|
||||
static unsigned int TOP_B; //The highest possible value for b
|
||||
//Instance variables
|
||||
std::vector<mpz_class> unique; //Holds all values in powers, except repeats
|
||||
public:
|
||||
//Constructor
|
||||
Problem29();
|
||||
virtual void solve();
|
||||
virtual std::string getString() const;
|
||||
virtual void reset();
|
||||
unsigned int getBottomA() const;
|
||||
unsigned int getTopA() const;
|
||||
unsigned int getBottomB() const;
|
||||
unsigned int getTopB() const;
|
||||
std::vector<mpz_class> getUnique() const;
|
||||
//Operational functions
|
||||
virtual void solve(); //Solve the problem
|
||||
virtual void reset(); //Reset the problem so it can be run again
|
||||
//Gets
|
||||
virtual std::string getString() const; //Return a string with the solution to the problem
|
||||
unsigned int getBottomA() const; //Returns the lowest possible value for a
|
||||
unsigned int getTopA() const; //Returns the highest possible value for a
|
||||
unsigned int getBottomB() const; //Returns the lowest possible value for b
|
||||
unsigned int getTopB() const; //Returns the highest possible value for b
|
||||
std::vector<mpz_class> getUnique() const; //Returns a vector of all the unique values for a^b
|
||||
};
|
||||
|
||||
/* Results:
|
||||
The number of unique values generated by a^b for 2 <= a <= 100 and 2 <= b <= 100 is 9183
|
||||
It took 1.464 seconds to solve this problem.
|
||||
It took an average of 1.651 seconds to run this problem over 100 iterations
|
||||
*/
|
||||
|
||||
#endif //PROBLEM29_HPP
|
||||
|
||||
Reference in New Issue
Block a user