# Cutting Paper Squares

# Cutting Paper Squares

JimNero009 + 3 comments Make sure you have enough memory to store the numbers ;)

- MG
mike_gorczynski + 0 comments Cheers mate. I was absolutely sure i figured it out so WHY IT WAS FAILING.

kinda silly, because it's a math problem, not core Java or Data structures problem.

- FH
fheil0815 + 0 comments kinda stupid. you would only need to add 1 line if the data types were correct.

- SD
sairajd044 + 0 comments Not a problem in Python

- ZW
SquatchingMan + 1 comment I thought I was doing it right, but then needed to change the pre-written int's in main to long int's. c++ for those who run into the same issue.

- SS
SHIVUCODE + 0 comments yes... thanks

n_nenkov + 0 comments Those are not really math problems, but "take-care-of-large-integers" problems !!!

Oh, c'mon you guys !!!

import java.util.*; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println((sc.nextLong())*(sc.nextLong())-1); } }

- CH
Bibliophage + 0 comments Each time a piece of paper is cut it becomes 2 pieces, adding 1 to the total number of pieces. Therefore to make x pieces from 1 piece there needs to be x-1 cuts, so the final answer is (n*m)-1.

Interestingly, this principle means that the cuts can be made in any order and configuration.

- JS
shell87301 + 0 comments Really??

#include <bits/stdc++.h> using namespace std; int main() { long long int n, m; cin >> n >> m; cout << m*n-1 << endl; return 0; }

- AM
atulmshr83 + 0 comments simple c++ code with data storing in as big datatype as long long int.

#include <bits/stdc++.h> using namespace std; unsigned long long int solve(unsigned long long int n, unsigned long long int m){ // Complete this function unsigned long long int row = n; unsigned long long int column = m; unsigned long long int count = (((row-1)*column)+(column-1)); return count; } int main() { unsigned long long int n; unsigned long long int m; cin >> n >> m; unsigned long long int result = solve(n, m); cout << result << endl; return 0; }

- AS
sudan_sahab + 0 comments for those who didnt misinterpreted the question like me he is saying that when you cut a page vertically into n pieces (e.g) then u will have new n pages and each of them u have to cut individually e.g i have 4*4 page and i made 3 vertical cuts then i have 4 vertical pages of height 4 each now i need to cut them horizontally 3 times each

- BK
the_brogrammerr + 0 comments This one works good :)

long long int solve(int n, int m) { long long int r=n-1; long long int c=m-1; long long int res=(r+c)+(r*c); return res;

}

shibaayanm + 0 comments This is in python3

def solve(n, m): p = n-1 q = m-1 return (p+q)+p*q

ARYAVARTTA + 0 comments Plz someone explain Mary's method of cutting the paper I didn't understand it.

Sort 42 Discussions, By:

Please Login in order to post a comment