Flooding in Japan has killed at least 24 as troops airlifted supplies to keep thousands of others alive.