  Generalized Tur\'an problems have been a central topic of study in extremal
combinatorics throughout the last few decades. One such problem is maximizing
the number of cliques of size $t$ in a graph of a fixed order that does not
contain any path (or cycle) of length at least a given number. Both of the
path-free and cycle-free extremal problems were recently considered and
asymptotically solved by Luo. We fully resolve these problems by characterizing
all possible extremal graphs. We further extend these results by solving the
edge-variant of these problems where the number of edges is fixed instead of
the number of vertices. We similarly obtain exact characterization of the
extremal graphs for these edge variants.
