Advertisement
Guest User

Untitled

a guest
Jul 18th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. package pb1;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class ControlNumber2 {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int N = Integer.parseInt(scanner.nextLine());
  10. int M = Integer.parseInt(scanner.nextLine());
  11. int controlNumber = Integer.parseInt(scanner.nextLine());
  12. int sum = 0;
  13. int moves = 0;
  14.  
  15. for (int i = 1; i <= N ; i++) {
  16. for (int j = M; j >= 1 ; j--) {
  17. sum = sum + (i * 2 + j * 3);
  18. moves++;
  19. }
  20. if (sum >= controlNumber) {
  21. System.out.printf("%d moves", moves);
  22. System.out.println();
  23. System.out.printf("Score: %d >= %d", sum , controlNumber);
  24. return;
  25. }
  26. else if (sum < controlNumber) {
  27. System.out.printf("%d moves", moves);
  28. }
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement