
SGU
文章平均质量分 80
ahfywff
这个作者很懒,什么都没留下…
展开
-
SGU101 Domino
将骨牌上的数字看作点,骨牌看作连接两点的边,然后求欧拉路径。#include #include int map[10][10], e[102][2], d[10];int ans[102][2], cnt, s;bool vis[102];void dfs(int u){ for (int i = 0; i <= 6; ++i) { if (map[原创 2012-04-04 17:08:32 · 740 阅读 · 0 评论 -
SGU102 Coprimes
求不大于n(1#include #include const int maxn = 10010;int n, cnt;int c[maxn], ys[maxn];bool p[maxn];int prime[maxn];void f() { // get primes memset(p, true, sizeof(p)); for (int i = 2;原创 2012-04-04 17:19:20 · 488 阅读 · 0 评论 -
sgu107 987654321 problem
问题:求n位数中平方数以“987654321”结束的数的个数。#include int main(){ int n; while (scanf("%d", &n) != EOF) { if (n < 9) printf("0\n"); else if (n == 9) printf("原创 2012-04-04 19:30:08 · 587 阅读 · 0 评论 -
SGU105 Div 3
105. Div 3time limit per test: 0.5 sec. memory limit per test: 4096 KBThere is sequence 1, 12, 123, 1234, ..., 12345678910, ... . Given first N elements of that sequence. You must determine原创 2012-04-04 20:03:40 · 840 阅读 · 0 评论 -
SGU126 Boxes
126. Boxestime limit per test: 0.5 sec. memory limit per test: 4096 KBThere are two boxes. There are A balls in the first box, and B balls in the second box (0 < A + B < 2147483648). It is p原创 2012-04-06 16:10:01 · 1110 阅读 · 0 评论 -
SGU104 Little Shop of Flowers (DP)
动态规划题用dp[i][j]表示把前i束花放在前j个花瓶里所得到的最大的美观值(i递推式为:dp[i][j] = max(dp[i][j-1], dp[i-1][j-1] + A[i][j]),dp[F][V]即为所求。题目还要求输出每束花的摆放位置,可以用pre[i][j]=0或1表示dp[i][j]是由dp[i][j-1]或dp[i-1][j-1] + A[i][j]得来的,然后递原创 2012-04-08 22:54:32 · 729 阅读 · 0 评论