the train cannot exceed a length of 1100 feet
Now, train A = 28 cars at 30 feet each
Therefore, Train A's total length = 28*30 = 840 feet < 1100 feet.
Now, train B = 22 cars at 40 feet each
Therefore, Train B's total length = 22*40 = 880 feet < 1100 feet.
Thus, both the trains meet the requirement.