# Cutting Paper Squares

# Cutting Paper Squares

celestial25 + 3 comments The reason beind mn - 1 can be understood like this. Forget about any grid for a moment, just imagine a simple piece of paper. Any cut on the paper will give rise to a new piece. If you make 1 cut to a single piece, it will give rise to 1 extra piece. If you further make a cut on any of those pieces, your count increases by one. In total, we need mn pieces, given each is 1x1. We don't have to make mn cuts, because there is already one piece at the beginning. So, we make mn - 1 cuts.

mukulodd1 + 1 comment Nice Explanation

celestial25 + 0 comments Thanks!

michellerodri247 + 0 comments The topic of cutting 3x2 piece of paper is clearly explained over this problem section. The clarity of the details is the main reason that I ma always find the page for a clear understanding of some topics printer driver is unavailable. The paper cut options explained clearly with the proper image help.

vk48962713 + 0 comments Nice explanation! Thank You!

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

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.

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

sairajd044 + 0 comments Not a problem in Python

Bad_Jim + 0 comments Or, more accurately, make sure you are using a 64 bit or larger integer type.

Bibliophage + 1 comment 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.

wichserpdx + 0 comments Your last line is spectacularly helpful and fun.

jessevsilverman + 1 comment For this problem to be ranked easy, it would be nice to see an example that wasn't one-dimensional solved all the way thru, to ensure we understand the rules for cutting. That is, sure, you can't fold or place them on top of eachother, but it is unclear whether you can hold multiple pieces of paper side by side as you cut. It seemed perfectly logical that one could, so I think an example where m, n both >1 would have cleared that question about the rules right up.

gidkessler + 1 comment ye i was thinking the exact same thing myself

jessevsilverman + 0 comments Actually, even Medium or Hard problems should just be harder or trickier to get working, not to understand what they are asking for. So what I said, but more so.

Admittedly, In Real Life, sometimes understanding what is actually needed, especially if it is non-identical to what was asked for, is a very important part of the problem. One big difference between here and LeetCode is that the problem descriptions tend to be more straightforward there, but more "fun" here. Glad they both exist.

tzych + 1 comment The answer is always one less than the number of 1x1 squares. Proof by induction: a single square takes zero cuts. If you have a rectangle of n squares that takes n-1 cuts, if you add a row or column of m squares, you are increasing the number of cuts by m as well, so the property is invariant.

Freiling + 1 comment So how did you come up with this? I found the answer but not elegantly. Did it take you a long time or trial-and-error or did you have a method for reducing this problem to its essential parts that made the formula clear?

geekster + 1 comment I found this a slightly different way, not as elegant as this logic, but still might be of interest to you.

I approached creating an equation by figuring out how many cuts I would need in each direction:

If I start in n orientation, I would cut (n-1) times. then for m orientation, I would cut (m-1) times for each of the n number of strips, so (m-1)*n.

Thus, the number of cuts needed would be

cuts= (n -1) +(m-1)*n.

cuts= n - 1 + m*n -n

cuts=m*n-1

S07_190030259 + 0 comments I thought of the same idea

n_nenkov + 1 comment 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); } }

JulioLeme + 0 comments Amazing, fantastic, the "less" always is the "more", this is the rule!!! Congratulations.

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.

SHIVUCODE + 0 comments yes... thanks

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; }

aryangarg1999 + 0 comments def solve(n, m):

`return n*m - 1`

vishwa9 + 0 comments which mathematical concept is used here

Sort 80 Discussions, By:

Please Login in order to post a comment