Generalized statistical mechanics for the N-body quantum problem — ideal gases