HDU3652(数位dp)】的更多相关文章

A - B-number Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string "13" and can be divided by 13. F…
从未见过的船新版本数位dp,,省去了预处理过程,直接进行计算 #include<bits/stdc++.h> using namespace std; #define ll long long ][][],n,len,bit[]; //dp[i][j][k]:到i位数,前面模13=j,前面是1|不是1|有13的状态已经确定,后面的数的个数 //mod:前面%13的余数,flag=0|1|2:pos+1位不是1|是1|有13出现过了,lim:数的限制 int dfs(int pos,int mo…
题目链接:https://vjudge.net/problem/HDU-3652 B-number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7415    Accepted Submission(s): 4346 Problem Description A wqb-number, or B-number for short, is…
B-number Problem Description A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string "13" and can be divided by 13. For example, 130 and 2613 are wqb-numbers, but 143 and 2639 are not. Your task…
B-number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5000    Accepted Submission(s): 2866 Problem Description A wqb-number, or B-number for short, is a non-negative integer whose decimal for…
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3652 题意:求1~n含有13且能被13整除的数的个数. 分析:数位dp,dp数组加一维来维护到pos位模13的余数,则dp[pos][mod][2]表示非限制条件下到pos位模13余mod且已含有13的总个数,dp[pos][mod][1]表示没含有13但前一位是1且模13余mod的总个数,dp[pos][mod][0]表示没含有13前一位不为1模13余mod的总个数... #include <cs…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3652 题意就是求区间内能被13整除并且包含”13“的数字的个数 感觉是比较中等的数位DP题目 我用的记忆化的方式做的 定义dp[len][mod][mark]; 其中len表示当前正在处理的位数或可以理解为还有len位需要处理,mod表示当前的总的余数(即从最高位到len位时所计算得到的余数) mark起标记作用 mark==0表示从最高位到i位还没有出现”13“: mak==1表示从最高位到i位没…
Description 题目大意:求小于n是13的倍数且含有'13'的数的个数. (1 <= n <= 1000000000) Solution 数位DP,题目需要包含13,且被13整除,所以状态应该多2个, \(F[i][j][k]\)表示位数为i,余数为j,包含13状态为k的方案数 其中k(0,1,2),2表示已经包含13,1表示上一个为1,否则为0 记忆化打法 Tips: 数组k维要开到3 DP数组只算一次,只需开始初始化一次 计算转移的k时的顺序 Code #include <c…
思路: 这里的状态分为3种,无13和末尾的1,无13且末尾为1,有13,然后DFS 等我搞清楚数位DP就来更新Orz 代码: #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<queue> #include<set> #include<vector> #include<map> #include<…
向大佬学习 第一次写博客有点紧张,也算是小萌新的突破吧 这次主要是总结一下校内的ACM比赛的各种题,主要是新思路以及学到的新知识 先放一张 下面开始说正事 题面 A wqb-number, or B-number for short, is a non-negative integer whose decimal form contains the sub- string "13" and can be divided by 13. For example, 130 and 2613…