This paper addresses a class of optimization problems with time-varying cost functions by proposing a fully distributed prescribed-time algorithm. The algorithm decomposes the overall optimization problem into three successive subproblems, which are solved sequentially. During the three stages of the algorithm, the estimation of the total cost function's average gradient information, consensus among the states, and tracking of the optimal state trajectories are achieved in turn. Given the segmentation strategy's demand for rapid convergence, the algorithm ensures convergence within a prescribed time. Using the Lyapunov method, it is shown that all three subproblems can be solved within any user-prescribed time, independent of the system's initial states or topology. To further exploit the independence of prescribed-time convergence from system states, the algorithm eliminates the reliance on system topology information in parameter settings by introducing adaptive parameters in place of traditional fixed ones, thus enabling fully distributed control. Finally, numerical simulations and an UAV target tracking experiment are conducted to validate the effectiveness and practicality of the proposed algorithm.