Skip to content

Instantly share code, notes, and snippets.

View bruteforceboy's full-sized avatar

Chibuoyim (Wilson) Ogbonna bruteforceboy

View GitHub Profile
@khaledismaeel
khaledismaeel / karatsuba.cpp
Created October 20, 2023 21:08
Karatsuba polynomial multiplication
#include <bits/stdc++.h>
using namespace std;
template<typename T>
void karatsuba(span<T> A, span<T> B, span<T> R, span<T> buf) {
if (A.size() > B.size())
swap(A, B);
const auto N = A.size(), M = B.size();
if (N <= 1 || N * M < 1024) {