整数
//三分极小值 int Left, Right; int mid, midmid; int mid_value, midmid_value; Left = minn; Right = maxn; while (Right - Left > 5) { mid = (Left + Right) / 2; midmid = (mid + Right) / 2; mid_value = Cal(mid); midmid_value = Cal(midmid); if (mid_value >= midmid_value) Left = mid; else Right = midmid; } int ans=Cal(Left) ; for(int i=Left+1 ;i<=Right ;i++) ans=min(ans,Cal(i)) ; printf("%d\n",ans) ; //三分极大值 int Left, Right; int mid, midmid; int mid_value, midmid_value; Left = minn; Right = maxn; while (Right - Left > 5) { mid = (Left + Right) / 2; midmid = (mid + Right) / 2; mid_value = Cal(mid); midmid_value = Cal(midmid); if (mid_value >= midmid_value) Right = midmid; else Left = mid; } int ans=Cal(Left) ; for(int i=Left+1 ;i<=Right ;i++) ans=max(ans,Cal(i)) ; printf("%d\n",ans) ;