这倒也是水题,我们可以建立一个数组,数组的下标就是编号,我们要注意的是浮点数乘法的结果要转化成整数,才能当做下标,因为题目给的是整数编号。
# include <stdio.h>
int main()
{int a[1000000] = { 0 }, n, t,i;double b,j;scanf("%d", &n);for ( i = 0; i < n; i++){scanf("%lf%d", &b, &t);for ( j= 1; j<=t; j++){if (a[(int)(j*b)] == 0){a[(int)(j * b)] = 1;continue;}if (a[(int)(j * b)] == 1){a[(int)(j * b)] = 0;continue;}}}for ( i = 0;; i++){if (a[i] == 1) {printf("%d", i);break;}}return 0;
}