|
|
вернуться в форумWhy my program got WA#1??? I think my program is correct. sum = 0; fl = 0; for (i = len; i > 0; i--) { if (s[i] == '1') { sum += i; fp[i] = ++count; } else fp[i] = count; } d = sum%(n+1); p = n+1-d; if (d == 0) printf("%s0\n", s); else if (d == 1) printf("%s1\n", s); else if (p <= count) { for (i = 1; i <= len; i++) { if (fl == 0 && fp[i] == p) { printf("0"); fl = 1; } printf("%c", s[i]); } } else { for (i = 1; i <= len; i++) { if (fl == 0 && fp[i]+i == p) { printf("1"); fl = 1; } printf("%c", s[i]); } } |
|
|