随笔分类 -  01. . . . . |zzOther

大视野 1016: [JSOI2008]最小生成树计数(最小生成树)
摘要:总结:此类题需要耐心观察规律,大胆猜想,然后证明猜想,得到有用的性质,然后解答。 简单的说:找隐含性质。传送门:http://61.187.179.132/JudgeOnline/problem.php?id=1016 题意:n个点m条边的图,问其最小生成树的个数(只要有一条边不同,就算不同)。n#include #include using namespace std;#define mod 31011#define N 200struct Edge{ int a, b, c; bool operator >=1; } ... 阅读全文

posted @ 2014-03-26 19:40 ShineCheng 阅读(307) 评论(0) 推荐(0)

UPC 2223: A-Number and B-Number(数位DP+二分)
摘要:积累点:1: (l&r)+((l^r)>>1) == (l+r)/2 2: 注意判断现在是否有限制。当枚举下一个量时,是(isQuery && j==end),不要搞错。传送门:http://acm.upc.edu.cn/problem.php?id=2223题意:能被7整除或者含7的数称为A-Number,所有A-Number从小到大写好,下标编号(从1开始),去掉那些下标为A-Number的数,剩下的数称为B-Number。求第N个B-Number是多少。思路:求A-Number就是简单的数位DP。dp[i][mod] 表示所有i位数中,%7==mod 阅读全文

posted @ 2014-03-14 20:18 ShineCheng 阅读(423) 评论(0) 推荐(0)

LightOJ - 1032 Fast Bit Calculations (数位DP)
摘要:类型:数位DP题意:[0,N]范围内所有数的二进制表示,问出现"11"的次数。(“111”计为两次) (0 ≤ N #include int num[50];long long dp[50][2];long long nowx;long long dfs(int i, int d, bool isQuery) { if (i == 1) { return 0; } long long &nowdp = dp[i][d]; if (!isQuery && ~nowdp) return nowdp; int end = isQuery?num[i-1]: 阅读全文

posted @ 2014-03-14 14:25 ShineCheng 阅读(233) 评论(0) 推荐(0)

LightOJ 1140: How Many Zeroes? (数位DP)
摘要:当前数位DP还不理解的点:1:出口用i==0的方式2:如何省略状态d(就是枚举下一个数的那个状态。当然枚举还是要的,怎么把空间省了)总结:1:此类DP,考虑转移的时候,应当同时考虑查询时候的情况。2:考虑x在第i位之后,能遍历多少数字,其答案为(x%10i-1+1) 3:这里的记忆化搜索不太一样喔,出口一定要写在递归里,不然,查询状态下差到出口就会出错了~类型:数位DP题意:求[A,B]区间内的所有数,写下来之后,0的个数。(a,b 为 unsigned int)思路:我的笨拙暴力状态:dp[i][d][okPre] 表示d开头的i位数,(okPre表示计算前导0的情况下,反之~),的0的个数 阅读全文

posted @ 2014-03-13 21:52 ShineCheng 阅读(440) 评论(0) 推荐(0)

HYSBZ 1026: windy数(数位DP)
摘要:类型:数位DP题意:不含前导零且相邻两个数字之差至少为2的正整数被称为windy数。问[A,B]之间windy数的个数。(1 #include #include using namespace std;int num[100];long long dp[20][10][2];long long dfs(int i, int d, bool preAllZero, bool isQuery) { if (!isQuery && ~dp[i][d][preAllZero]) return dp[i][d][preAllZero]; if (i == 1) { return... 阅读全文

posted @ 2014-03-11 23:53 ShineCheng 阅读(416) 评论(0) 推荐(0)

UPC 2219: A^X mod P
摘要:题形:另类快速幂题意:f(x) = K, x = 1f(x) = (a*f(x-1) + b)%m , x > 1Now, Your task is to calculate( A^(f(1)) + A^(f(2)) + A^(f(3)) + ...... + A^(f(n)) ) modular P. 1 #include #include long long n, A, K, a, b, m, P;long long p1[100005], p2[100005];int main() { int t; scanf("%d", &t); int cas = 阅读全文

posted @ 2014-03-09 20:41 ShineCheng 阅读(246) 评论(0) 推荐(0)

UVA - 10196:Check The Check
摘要:类型:简单模拟大致题意:已知国际象棋行棋规则,给你一个局面,问是否将军?谁将谁的军?(保证不会同时将军)思路:都以小写字母 测试 是否将 大写字母。 然后一个局面测两次(一次直接测,一次反转棋盘,同时大小写互换,测)原题:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=21173The ProblemYour task is to write a program that reads a chess board configuration and answers if there's a king under at 阅读全文

posted @ 2014-03-03 12:16 ShineCheng 阅读(410) 评论(0) 推荐(0)

H.High String
摘要:原题:Description:We define the srting which can satisfy the following conditions as High String:1)The string only contains six kinds of characters: A,B,C,D,E and F;2)cont(A) = count(b), count(c) = cont(D),and count(E) = count(F). count(X) means the number of character X in the string;3) Except the str 阅读全文

posted @ 2013-05-19 22:33 ShineCheng 阅读(247) 评论(0) 推荐(0)

导航