Gain d'1 seconde.
This commit is contained in:
parent
927bcaff9a
commit
971acfe372
33
main.cpp
33
main.cpp
@ -1,6 +1,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <vector>
|
||||||
#include <boost/crc.hpp>
|
#include <boost/crc.hpp>
|
||||||
|
#include <omp.h>
|
||||||
#include <frozen/unordered_map.h>
|
#include <frozen/unordered_map.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,15 +87,15 @@ struct NumberBase26 final {
|
|||||||
* Tant que la retenue se propage à travers les digit, il faut les mettre à 'A' et
|
* Tant que la retenue se propage à travers les digit, il faut les mettre à 'A' et
|
||||||
* poursuivre jusqu'à rencontrer un caractère != 'Z'
|
* poursuivre jusqu'à rencontrer un caractère != 'Z'
|
||||||
*/
|
*/
|
||||||
for (auto iter = data.rbegin(); iter != data.rend(); ++iter) {
|
for (std::size_t i = data.size() - 1; 0 <= i; --i) {
|
||||||
if (retenue) {
|
if (retenue) {
|
||||||
number = lut.at(*iter) + 1;
|
number = lut.at(data[i]) + 1;
|
||||||
}
|
}
|
||||||
if (number == valMax) {
|
if (number == valMax) {
|
||||||
*iter = 'A';
|
data[i] = 'A';
|
||||||
retenue = true;
|
retenue = true;
|
||||||
} else {
|
} else {
|
||||||
*iter = alphabet[number];
|
data[i] = alphabet[number];
|
||||||
retenue = false;
|
retenue = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -232,11 +234,30 @@ int main() {
|
|||||||
constexpr std::size_t maxDig = maxDigits(maxCompute);
|
constexpr std::size_t maxDig = maxDigits(maxCompute);
|
||||||
|
|
||||||
NumberBase26<maxDig> number_base_26{ alphabet };
|
NumberBase26<maxDig> number_base_26{ alphabet };
|
||||||
|
std::vector<std::size_t> crcs;
|
||||||
|
std::vector<char> results;
|
||||||
|
results.reserve(maxDig * maxCompute);
|
||||||
|
crcs.reserve(maxCompute);
|
||||||
|
|
||||||
|
const double start = omp_get_wtime();
|
||||||
for (size_t i = 0; i < maxCompute; ++i, ++number_base_26) {
|
for (size_t i = 0; i < maxCompute; ++i, ++number_base_26) {
|
||||||
const auto crc = ~(getCrc32(std::string_view{ number_base_26.data.data(), maxDig }));
|
const auto crc = ~(getCrc32(std::string_view{ number_base_26.data.data(), maxDig }));
|
||||||
if (std::find(cheat_list.cbegin(), cheat_list.cend(), crc) != cheat_list.cend())
|
if (std::find(cheat_list.cbegin(), cheat_list.cend(), crc) != cheat_list.cend()) {
|
||||||
std::cout << number_base_26 << ":0x" << std::hex << crc << '\n';
|
crcs.emplace_back(crc);
|
||||||
|
for (const char &j : number_base_26.data) {
|
||||||
|
results.emplace_back(j);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const double stop = omp_get_wtime();
|
||||||
|
crcs.shrink_to_fit();
|
||||||
|
results.shrink_to_fit();
|
||||||
|
for (size_t i = 0; i < crcs.size(); ++i) {
|
||||||
|
for (size_t j = 0; j < maxDig; ++j) {
|
||||||
|
std::cout << results[i * maxDig + j];
|
||||||
|
}
|
||||||
|
std::cout << " : 0x" << std::hex << crcs[i] << '\n';
|
||||||
|
}
|
||||||
|
std::cout << "Temps : " << stop - start << 's' << std::endl;
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user