Problems
A題:水題,先計算總和,盡量往大了取,所以答案就是sum / x + (sum % x != 0)。
B題:最多的情況是全是DIV2,最少的情況是盡量有DIV1和DIV2和開,用一個vis數組記錄已經開過的場,for循環找過去即可。<喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+Q8zio7puuPYwo6xtuPYxo6wx1rvE3NPQMbj2u/IyuPbX6bPJ0rvG8KOsyLu689PQbrj2MKOs1+7J2b7N0qpuIC0gMbj2MaOs1+624L/J0tTT0ChuICYjNDM7IDEpICogMiCjqDG/ydLUtuC3xcG9sd+jqcv50tTPyMXQts9uIC0gMSA8PSBtIDw9IChuICYjNDM7IDEpICogMqOsyLu689TayKXEo8Tit8W+zb/J0tTBy6GjPC9wPgo8cD5EzOKjurzH0uS7r8vRy/ejrGRwW3NdW21dtPqx7byvus/OqnOjrMihxKPOqm1vtcTXtMyso6zIu7rzyKXSu7j20MK1xMr919a3xdTauvPD5qOsbbHks8kobW8gKiAxMCAmIzQzOyBudW0pICUgbSy9+NDQvMfS5Luvy9HL97y0v8mhozwvcD4KPHA+tPrC66O6PC9wPgo8cD5BzOKjujwvcD4KPHA+PHByZSBjbGFzcz0="brush:java;">#include
#include#include int x, n, vis[4005]; int main() { scanf("%d%d", &x, &n); int v, d1, d2; while (n--) { scanf("%d", &v); if (v == 1) { scanf("%d%d", &d1, &d2); vis[d1] = 1; vis[d2] = 1; } else { scanf("%d", &d2); vis[d2] = 1; } } vis[0] = 1; int ans1 = 0, ans2 = 0, i; for (i = 1; i < x; i++) if (!vis[i]) ans1++; for (i = 1; i < x; i++) if (!vis[i] && !vis[i - 1]) { ans2++; vis[i] = vis[i - 1] = 1; } for (i = 1; i < x; i++) if (!vis[i]) ans2++; printf("%d %d\n", ans2, ans1); return 0; }
#include#include int n, m; int main() { scanf("%d%d", &n, &m); if (m < n - 1 || m > (n + 1) * 2) { printf("-1\n"); return 0; } if (m - (n - 1) * 2 == 1) printf("1"); if (m - (n - 1) * 2 >= 2) printf("11"); int mm; if (m > (n - 1) * 2) mm = (n - 1) * 2; else mm = m; int m2 = mm - (n - 1); int m1 = (n - 1) - m2; int nn = n; while (m2--) { if (nn--) printf("0"); printf("11"); } while (m1--) { if (nn--) printf("0"); printf("1"); } if (nn--)printf("0"); if (m - (n - 1) * 2 == 3) printf("1"); if (m - (n - 1) * 2 == 4) printf("11"); printf("\n"); return 0; }
#include#include char str[20]; int num[20], m, n, vis[(1<<18)][105]; __int64 dp[(1<<18)][105]; __int64 dfs(int s, int mo) { __int64 &ans = dp[s][mo]; if (vis[s][mo]) return ans; vis[s][mo] = 1; int v[10]; memset(v, 0, sizeof(v)); if (s == (1<