Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <chrono>
- using namespace std;
- const int gridsize = 20;
- long long grid[gridsize+2][gridsize+2];
- int main() {
- // YOU COULD DO THIS OR JUST USE MATH :)
- // 40! / ((20!)^2)
- grid[1][1] = 1;
- auto start = std::chrono::steady_clock::now();
- for (int i = 1; i <= gridsize+1; i++) {
- for (int j = 1; j <= gridsize+1; j++) {
- grid[i][j] += grid[i][j-1] + grid[i-1][j];
- }
- }
- auto stop = std::chrono::steady_clock::now();
- auto duration = std::chrono::duration_cast<std::chrono::nanoseconds>((stop - start) / 1000);
- cout << "Time taken by function: " << duration.count() << " nanoseconds" << endl;
- cout << grid[gridsize+1][gridsize+1] << "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement