单项选择题

已知函数y=acosx+1/2cos2x(其中a为常数)在x=π/2处取得极值,则a=()

A.0
B.1
C.2
D.3