Exhibit 5.1 CONSENT OF INDEPENDENT ACCOUNTANTS We hereby consent to the incorporation by reference in the Registration Statement of PEC Solutions, Inc. on Form S-8 (No. 333-35538) of PEC Solutions, Inc. of our report dated February 7, 2001, relating to the consolidated financial statements of Troy Systems, Inc. and subsidiary. /s/ Rubino & McGeehin, Chartered Bethesda, MD February 1, 2002