/* * File name: q273.c * Author: ZhuTing * School: PKU Computer Science * Time: 2013-09-15 */#include#include int saturating_add(int x, int y){ int w = (sizeof(int) << 3) - 1; int mark1 = ~(x ^ y) >> w; int mark2 = ((x + y) ^ y) >> w; int mark = mark1 & mark2; int pos = x >> w; int ans = ((x + y) & (~(mark)))+ (mark & ((((-1) ^ (1 << w)) & ~pos) + ((1 << w) & pos))); return ans;}int main(){ int a = 0, b = 0; scanf("%d%d", &a, &b); printf("%d\n", saturating_add(a, b)); return 0;}