14.01.2013 Views

Soluciones y Explicación de los problemas ACM ... - ICPC Bolivia

Soluciones y Explicación de los problemas ACM ... - ICPC Bolivia

Soluciones y Explicación de los problemas ACM ... - ICPC Bolivia

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Explicaciones a <strong>los</strong> <strong>problemas</strong> South American Regionals 2008 19<br />

int check(int x) {<br />

int acc, i;<br />

acc = 0;<br />

for (i = 0; i < MAX; i++) {<br />

acc /= x;<br />

acc += lhs.c[i];<br />

if (acc % x != 0) {<br />

return 0;<br />

}<br />

}<br />

return (acc == 0);<br />

}<br />

int main() {<br />

int TC;<br />

int h, i, j, max, fail;<br />

char *p;<br />

char buf[2*MAX+2];<br />

for (;;) {<br />

gets(buf);<br />

if (buf[0] == ’=’) {<br />

break;<br />

}<br />

max = 1;<br />

for (p = buf; *p; p++) {<br />

if (*p == ’=’) {<br />

continue;<br />

}<br />

if (*p - ’0’ > max) {<br />

max = *p - ’0’;<br />

}<br />

}<br />

lhs = poly_read(buf);<br />

for (p = buf; *p != ’=’; p++)<br />

;<br />

rhs = poly_read(++p);<br />

for (i = 0; i < MAX; i++) {<br />

lhs.c[i] -= rhs.c[i];<br />

}<br />

for (j = 0; j < MAX; j++) {<br />

if (lhs.c[j]) break;<br />

}<br />

if (j == MAX) {<br />

printf("%d+\n", max+1);<br />

continue;<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!