Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package TheExam;
- import java.util.Scanner;
- /**
- * Created by Minito on 7.5.2017 г..
- */
- public class Pr06 {
- public static void main(String[] args) {
- Scanner console = new Scanner(System.in);
- int m = Integer.parseInt(console.nextLine());
- int n = Integer.parseInt(console.nextLine());
- int l = Integer.parseInt(console.nextLine());
- int specNum = Integer.parseInt(console.nextLine());
- int contNum = Integer.parseInt(console.nextLine());
- boolean r1;
- boolean r2 = false;
- for (int i = m; i >= 1; i--) {
- for (int j = n; j >= 1; j--) {
- for (int k = l; k >= 1; k--) {
- int sum = Integer.valueOf(String.valueOf(i) + String.valueOf(j) + String.valueOf(k));
- r1 = false;
- if (sum % 3 == 0 && !r1) {
- specNum += 5;
- r1 = true;
- } else if (sum % 10 == 5 && !r1) {
- specNum -= 2;
- r1 = true;
- } else if (sum % 2 == 0 && !r1) {
- specNum *= 2;
- }
- if (specNum >= contNum) {
- System.out.print("Yes! Control number was reached! Current special number is " + specNum + ".");
- r2 = true;
- break;
- }
- }
- if (r2){
- break;
- }
- }if (r2){
- break;
- }
- }if (!r2){
- System.out.printf("No! %d is the last reached special number.",specNum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement