wa了好多次没、一直找不到原因。后来就在网上搜测试数据,得出一个结论,放弃google吧,zf对google太狠了,果断用bing吧http://www.acm-japan.org/past-icpc/domestic2004/index.html测试数据地址。
//2614968 2011-08-04 14:43:52 Accepted 2164 C++ 0 180 ylwh!
#include <stdio.h>
#include <stdlib.h>
int main()
{
char s[2][55];
int n, r, p, c, i, j;
bool k, x;
while(scanf("%d%d", &n, &r) && n)
{
k = false;
x = true;
for(i=1, j=n; i<=n; i++, j--)
s[0][i] = s[1][i] = j;
while(r--)
{
x = !k;
scanf("%d%d", &p, &c);
for(i = 1, j = p; i <= c; i++, j++)
s[x][i] = s[k][j];
for(i = c+1, j = 1; j < p; i++, j++)
s[x][i] = s[k][j];
for(i = p + c; i <= n; i++) // 没有考虑上一次的变动可能改变了底部的数据
s[x][i] = s[k][i];
k = x;
}
printf("%d\n", s[x][1]);
}
return 0;
}