Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Exam19March2017Evening;
- import java.util.Scanner;
- public class P06_ControlNumber {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int N = Integer.parseInt(scanner.nextLine());
- int M = Integer.parseInt(scanner.nextLine());
- int control = Integer.parseInt(scanner.nextLine());
- boolean isReached = true;
- int counter = 0;
- int sum = 0;
- for (int i = 1; i <= N; i++) {
- for (int j = M; j >= 1; j--) {
- sum = sum + (i*2) + (j*3);
- counter++;
- if (sum>=control){
- break;
- }
- }
- if (sum>=control){
- break;
- }
- }
- if (sum>=control){
- System.out.println(counter + " moves");
- System.out.printf("Score: %d >= %d", sum, control);
- } else {
- System.out.println(counter + " moves");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement