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