Advertisement
Guest User

Untitled

a guest
May 4th, 2017
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ControlNumber {
  4.     public static void main(String[] args) {
  5.         Scanner input = new Scanner(System.in);
  6.         int n=Integer.parseInt(input.nextLine());
  7.         int m=Integer.parseInt(input.nextLine());
  8.         int controlNumber=Integer.parseInt(input.nextLine());
  9.         int moves=0;
  10.         int sum=0;
  11.         for (int i = 1; i<=n ; i++) {
  12.             for (int j = m; j>=1 ; j--) {
  13.                 sum+=(i*2+3*j);
  14.                 moves++;
  15.                 if(sum>=controlNumber){
  16.                     break;
  17.                 }
  18.             }
  19.         }
  20.         if(sum>=controlNumber){
  21.             System.out.printf("%d moves\nScore: %d >= %d",moves,sum,controlNumber);
  22.         }else{
  23.             System.out.printf("%d moves",moves);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement