aboutsummaryrefslogtreecommitdiff
path: root/2017/US Open/Platinum/cowbasic.cpp
diff options
context:
space:
mode:
authorTa180m2019-10-06 20:15:18 -0500
committerGitHub2019-10-06 20:15:18 -0500
commit0b6d71a3c5742fffe7d44eb48161ae80019aa413 (patch)
tree9e58b17b85b1f44d31fab21c08065e1cd9c412f3 /2017/US Open/Platinum/cowbasic.cpp
parent09798454779c68cbc09d3aa4ced06f4132db67d3 (diff)
Update cowbasic.cpp
Diffstat (limited to '2017/US Open/Platinum/cowbasic.cpp')
-rw-r--r--2017/US Open/Platinum/cowbasic.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/2017/US Open/Platinum/cowbasic.cpp b/2017/US Open/Platinum/cowbasic.cpp
index bf1343d..8ef44c9 100644
--- a/2017/US Open/Platinum/cowbasic.cpp
+++ b/2017/US Open/Platinum/cowbasic.cpp
@@ -38,15 +38,13 @@ void mult(matrix& A, matrix& B) { // B = A * B;
matrix res(d + 1, vi(d + 1, 0));
for (int i = 0; i <= d; i++) {
for (int j = 0; j <= d; j++) {
- for (int k = 0; k <= d; k++) {
- res[i][j] = ((ll)A[i][k] * (ll)B[k][j] + res[i][j]) % MOD;
- }
+ for (int k = 0; k <= d; k++) res[i][j] = ((ll)A[i][k] * (ll)B[k][j] + res[i][j]) % MOD;
}
}
B = res;
}
-void pow(matrix& A, int n) { // A ^ n
+void pow(matrix& A, int n) { // A = A ^ n
matrix res(d + 1, vi(d + 1, 0));
for (int i = 0; i <= d; i++) res[i][i] = 1;
while (n) {
@@ -62,13 +60,11 @@ int main() {
str input;
while (getline(cin, input)) program.push_back(input);
-
for (auto& line : program) { // Record variables
stringstream ss(line);
str n; ss >> n;
if (islower(n[0]) && var.find(n) == var.end()) var[n] = d++;
}
-
mat_st.push_back({});
mat_st.back().resize(d + 1, vi(d + 1, 0));
for (int i = 0; i <= d; i++) mat_st.back()[i][i] = 1;