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