Created
August 19, 2020 12:08
-
-
Save staffordsmith83/eac60d2e992ad511cb49d6c69be884e6 to your computer and use it in GitHub Desktop.
We have a block of chocolate with n * m dimensions (of pieces of chocolate!). This method determines if it is possible to break off exactly K segments from the chocolate with a single straight line: vertical or horizontal. The program gets an input of three integers: n, m, k.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
class Main { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
int n = scanner.nextInt(); | |
int m = scanner.nextInt(); | |
int k = scanner.nextInt(); | |
if (k > (n * m)) { | |
System.out.print("NO"); | |
} else { | |
if (k % n == 0 && k >= n || k % m == 0 && k >= m) { | |
System.out.print("YES"); | |
} else { | |
System.out.print("NO"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment