Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int m = Integer.parseInt(scanner.nextLine()),
- n = Integer.parseInt(scanner.nextLine()),
- l = Integer.parseInt(scanner.nextLine()),
- special = Integer.parseInt(scanner.nextLine()),
- control = Integer.parseInt(scanner.nextLine());
- for (int i = m; i > 0; i--) {
- for (int j = n; j > 0; j--) {
- for (int k = l; k > 0; k--) {
- int num = i * 100 + j * 10 + k;
- if (num % 3 == 0) {
- special += 5;
- } else if (num % 5 == 0) {
- special -= 2;
- } else if (num % 2 == 0) {
- special *= 2;
- }
- if (special >= control) {
- System.out.println("Yes! Control number was reached! Current special number is " + special + ".");
- System.exit(0);
- }
- }
- }
- }
- System.out.println("No! " + special + " is the last reached special number.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement