Add solution for 2015 Day 25
This commit is contained in:
1 parent
4de110a517
commit
9237445a13
6 files changed
+40
-12
No files matched your search
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <functional>
|
||||
@@ -607,6 +609,24 @@ struct Helper
|
||||
return currentRes;
|
||||
}
|
||||
|
||||
static uint64_t FastExponentiation(uint64_t start, uint64_t multiplication, uint64_t power, uint64_t mod)
|
||||
{
|
||||
while (power > 0)
|
||||
{
|
||||
if (power % 2 == 0)
|
||||
{
|
||||
multiplication = (multiplication * multiplication) % mod;
|
||||
power /= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
start = (start * multiplication) % mod;
|
||||
power--;
|
||||
}
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
||||
// Input - Puzzle input
|
||||
// Function - bool(int64_t);
|
||||
// Given index, return whether the index should increase next
|
||||
|
||||
Reference in new issue
Block a user