Ubuntu 下mysql编译安装
#include <stdio.h> #include <string.h> int n, p, k, vis[105]; int i; int main() { scanf("%d%d%d", &n, &p, &k); for (i = p - k; i <= p + k; i++) { if (i >= 1 && i <= n) vis[i] = 1; } for (i = 1; vis[i] == 0; i++); if (i == 1) { if (i == p) printf("(%d)", i); else printf("%d", i); } else { if (i == p) printf("<< (%d)", i); else printf("<< %d", i); } i++; for (; vis[i]; i++) { if (i == p) printf(" (%d)", i); else printf(" %d", i); } if (i != n + 1) printf(" >>\n"); else printf("\n"); return 0; }
#include <stdio.h> #include <string.h> int n; char str[55]; __int64 mi[55]; void init() { mi[0] = 1; for (int i = 1; i <= 50; i++) mi[i] = mi[i - 1] * 2; } int main() { init(); scanf("%d%s", &n, str); __int64 ans = 0; for (int i = 0; i < n; i++) if (str[i] == ‘B‘) ans += mi[i]; printf("%I64d\n", ans); return 0; }C题:
#include <stdio.h> #include <string.h> #define max(a,b) ((a)>(b)?(a):(b)) __int64 a, b; __int64 cal(int num) { __int64 ans = 0; ans += num - 1 + (a - (num - 1)) * (a - (num - 1)); __int64 k = b / (num + 1) + 1; __int64 kk = k * (num + 1) - b; ans -= (kk * (k - 1) * (k - 1) + (num + 1 - kk) * k * k); return ans; } void print(int x) { int k = b / x + 1; int kk = k * x - b; int kkk = x - kk; int sb = x - 2; int sbb = 1; while (kk) { for (int i = 0; i < k - 1; i++) { printf("x"); } kk--; if (sb != 0) { printf("o"); sb--; } else if (sbb != 0) { for (int i = 0; i < a - (x - 2); i++) printf("o"); sbb--; } } while (kkk) { for (int i = 0; i < k; i++) { printf("x"); } kkk--; if (sb != 0) { printf("o"); sb--; } else if (sbb != 0) { for (int i = 0; i < a - (x - 2); i++) printf("o"); sbb--; } } printf("\n"); } int main() { __int64 ans = -10000000000000000; int ansv; scanf("%I64d%I64d", &a, &b); if (b == 0) { printf("%I64d\n", a * a); for (int i = 0; i < a; i++) printf("o"); printf("\n"); return 0; } if (a == 0) { printf("%I64d\n", -b * b); for (int i = 0; i < b; i++) printf("x"); printf("\n"); return 0; } for (int i = 1; i <= a; i++) { __int64 t = cal(i); if (t > ans) { ans = t; ansv = i + 1; } } printf("%I64d\n", ans); print(ansv); return 0; }D题:
#include <stdio.h> #include <string.h> const int N = 2005; int n, m, r, c, rv[N], cv[N], i, j; double dp[N][N]; int main() { scanf("%d%d", &n, &m); r = c = n; int a, b; while (m--) { scanf("%d%d", &a, &b); if (rv[a] == 0) r--; if (cv[b] == 0) c--; rv[a] = 1; cv[b] = 1; } for (i = 1; i <= n; i++) { dp[i][0] = dp[i - 1][0] + (double)n/i; dp[0][i] = dp[0][i - 1] + (double)n/i; } for (i = 1; i <= n; i++) { for (j = 1; j <= n; j++) { dp[i][j] = n * n; dp[i][j] += dp[i - 1][j - 1] * i * j; dp[i][j] += dp[i - 1][j] * i * (n - j); dp[i][j] += dp[i][j - 1] * (n - i) * j; dp[i][j] /= (n * n - (n - i) * (n - j)); } } printf("%.10lf\n", dp[r][c]); return 0; }E题:
#include <stdio.h> #include <string.h> int n, i; int main() { scanf("%d", &n); if (n == 5) printf("1 2 3\n1 3 3\n2 4 2\n4 5 1\n3 4\n3 5\n"); else { for (i = 1; i <= n/2; i++) printf("%d %d 1\n", i, i+n/2); for (i = n/2 + 1; i <= n - 1; i++) printf("%d %d %d\n", i, i + 1, 2 * (i - n/2) - 1); for (i = 1; i <= n/2 - 1; i++) printf("%d %d\n", i, i +1); printf("1 3\n"); } return 0; }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。