Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////////////////////////////////
- const getGets = arr => {
- let index = 0;
- return () => {
- const toReturn = arr[index];
- index += 1;
- return toReturn;
- };
- };
- // this is the test
- const test = ["100 200"];
- const gets = this.gets || getGets(test);
- const print = this.print || console.log;
- //////////////////////////////////////////////////////////////////////////
- const [row, col] = gets()
- .split(" ")
- .map(Number);
- //console.log(row, col);
- const isInside = (r, c) => {
- let result = false;
- if (r > 0 && c > 0 && r < row - 1 && c < col - 1) result = true;
- return result;
- };
- let sum = 0n;
- const two = 2n;
- if (row !== col) {
- for (let r = 0; r < row; r++) {
- for (let c = r % 2 ? 1 : 0; c < col; c += 2) {
- //console.log(r, c);
- let temp = two ** BigInt(r + c);
- if (isInside(r, c)) {
- temp += temp;
- }
- sum += temp;
- }
- }
- } else {
- for (let i = 0; i < row; i++) {
- let temp = two ** BigInt(r + c);
- //console.log(temp);
- sum += temp;
- }
- }
- print(sum.toString());
Advertisement
Add Comment
Please, Sign In to add comment