cleanup
This commit is contained in:
parent
ede4232338
commit
91d9f6e340
16
2019/16.cpp
16
2019/16.cpp
|
@ -8,12 +8,12 @@ using namespace aocpp;
|
|||
|
||||
namespace {
|
||||
|
||||
auto FFT(std::size_t start, std::vector<std::int8_t> const& prev)
|
||||
auto FFT(std::size_t const start, std::vector<std::int8_t> const& prev)
|
||||
{
|
||||
std::vector<std::int8_t> result;
|
||||
std::vector<std::int32_t> partial_sums;
|
||||
auto n = prev.size();
|
||||
result.resize(n);
|
||||
result.reserve(n);
|
||||
partial_sums.reserve(n+1);
|
||||
partial_sums.push_back(0);
|
||||
|
||||
|
@ -22,14 +22,14 @@ auto FFT(std::size_t start, std::vector<std::int8_t> const& prev)
|
|||
partial_sums.push_back(acc += x);
|
||||
}
|
||||
|
||||
for (std::size_t i = start; i < n+start; i++) {
|
||||
for (std::size_t i = 0; i < n; i++) {
|
||||
std::int32_t acc = 0;
|
||||
for (std::size_t offset = i; offset < n+start; offset += 4*(i+1)) {
|
||||
acc += partial_sums[std::min(n,offset-start + i + 1)] - partial_sums[std::min(n, offset-start)];
|
||||
acc -= partial_sums[std::min(n, offset-start + 3*(i + 1))] - partial_sums[std::min(n, offset-start + 2*(i + 1))];
|
||||
auto step = i+start+1;
|
||||
for (std::size_t offset = i; offset < n; offset += 4*step) {
|
||||
acc += partial_sums[std::min(n, offset + 1*step)] - partial_sums[std::min(n, offset )];
|
||||
acc -= partial_sums[std::min(n, offset + 3*step)] - partial_sums[std::min(n, offset + 2*step)];
|
||||
}
|
||||
|
||||
result[i-start] = std::abs(acc % 10);
|
||||
result.push_back(std::abs(acc % 10));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user