-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem 29.cpp
More file actions
45 lines (34 loc) · 986 Bytes
/
Copy pathProblem 29.cpp
File metadata and controls
45 lines (34 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <iostream>
#include <list>
#include "include/BigNumber.hpp"
//#define DEBUG
std::string power(unsigned short num, unsigned short pow) {
BigNumber ret("1");
for(unsigned short i = 0; i < pow; i++) {
ret *= num;
}
return ret.getNumber();
}
int main() {
std::list<std::string> powers;
for(unsigned short num = 2; num <= 100; ++num) {
for(unsigned short pow = 2; pow <= 100; ++pow) {
powers.insert(powers.end(), power(num, pow));
#ifdef DEBUG
auto lastElement = powers.end();
--lastElement;
std::cout << num << "^" << pow << "=" << *lastElement << '\n';
#endif // DEBUG
}
}
powers.sort();
powers.unique();
std::cout << powers.size() << '\n';
#ifdef DEBUG
for(auto it = powers.begin(); it != powers.end(); it++) {
std::cout << *it << ',';
}
std::cout << '\n';
#endif // DEBUG
return 0;
}