Given a specific computational problem, write a C++ solution and explain how you would optimize it for cache locality in Fluent-scale code.