绞尽脑汁

rack one's brains, beat one's brains, rack one's wits...