Answer to Question #59008 in Java | JSP | JSF for Jian

Question #59008
Input
The input consists of several test cases. In each line of input, there are two integers 1 ≤ M ≤ 300, the
number of rows in the chocolate and 1 ≤ N ≤ 300, the number of columns in the chocolate. The input
should be processed until end of file is encountered.

Output
For each line of input, your program should produce one line of output containing an integer indicating
the minimum number of cuts needed to split the entire chocolate into unit size pieces.
1
Expert's answer
2016-04-11T10:19:04-0400
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
public static void main(String[] args) throws FileNotFoundException {
File myFile = new File("file.txt");
Scanner sc = new Scanner(myFile);
while(sc.hasNext()){
int M = sc.nextInt();
int N = sc.nextInt();
System.out.println(M + N - 2);
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS