import java.util.Scanner;
public class Main {
static int col=0;
public static void main(String[] args) {
Container c1 =new Container(10,4,2.5);
v2(c1);
System.out.println(col);
}
static void v2(Container container) {
System.out.println("Ведите размеры авто");
Scanner scanner = new Scanner(System.in);
double l= scanner.nextInt();
double h=scanner.nextInt();;
double w=scanner.nextInt();;
Car car = new Car(l,h,w);
if (container.hashCode() >= car.hashCode()) {
container.widht = container.widht - car.widht;
container.height= container.height - car.height;
container.leng = container.leng - car.leng;
col++;
v2(container);
}
}
}
public class Car {
final double leng;
final double height;
final double widht;
Car(double leng,double height,double widht){
this.leng=leng;
this.height=height;
this.widht=widht;
}
@Override
public int hashCode() {
return (int) (leng+height+widht);
}
}
public class Container {
static double leng;
static double height;
static double widht;
Container(double leng,double height,double widht){
this.leng=leng;
this.height=height;
this.widht=widht;
}
@Override
public int hashCode() {
return (int) (leng+height+widht);
}
}
Заменим буквы А, О, У на 0, 1, 2(для них порядок очевиден – по возрастанию)
Выпишем начало списка, заменив буквы на цифры:
1. 00000
2. 00001
3. 00002
4. 00010
Полученная запись есть числа, записанные в троичной системе счисления в порядке возрастания. Тогда на 61 месте будет стоять число 60 (т. к. первое число 0). Переведём число 60 в
троичную систему (деля и снося остаток справа налево):
60/ 3 = 20 (0)
20 / 3 = 6 (2)
6 / 3 = 2 (0)
2 / 3 = 0(2)
02020
В троичной системе 60 запишется как 02020. Произведём обратную замену и получим АУАУА
Объяснение: