mirror of
https://bitbucket.org/Mattrixwv/projecteulercpp.git
synced 2025-12-06 17:13:59 -05:00
Updated to work with the new libraries
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
//ProjectEuler/ProjectEulerCPP/headers/Problems/Problem29.hpp
|
||||
//Matthew Ellison
|
||||
// Created: 10-06-19
|
||||
//Modified: 08-28-20
|
||||
//Modified: 07-02-21
|
||||
//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) 2020 Matthew Ellison
|
||||
Copyright (C) 2021 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
|
||||
@@ -23,14 +23,12 @@
|
||||
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 PROBLEM29_HPP
|
||||
#define PROBLEM29_HPP
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <gmpxx.h>
|
||||
#include "Problem.hpp"
|
||||
@@ -41,9 +39,9 @@ private:
|
||||
//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 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
|
||||
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:
|
||||
@@ -53,17 +51,20 @@ 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
|
||||
virtual std::string getResult()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 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
|
||||
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
|
||||
size_t getNumUnique() const; //Returns the number of 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 an average of 1.651 seconds to run this problem over 100 iterations
|
||||
*/
|
||||
|
||||
#endif //PROBLEM29_HPP
|
||||
|
||||
#endif //PROBLEM29_HPP
|
||||
|
||||
Reference in New Issue
Block a user