【数位DP】 HDU 4722 Good Numbers】的更多相关文章

题目传送门 /* 找规律/数位DP:我做的时候差一点做出来了,只是不知道最后的 is_one () http://www.cnblogs.com/crazyapple/p/3315436.html 数位DP:http://blog.csdn.net/libin56842/article/details/11580497 */ #include <cstdio> #include <iostream> #include <algorithm> #include <c…
原题直通车: HDU  4722  Good Numbers 题意: 求区间[a,b]中各位数和mod 10==0的个数. 代码: #include<iostream> #include<cstdio> #include<cstring> #include<cmath> using namespace std; int f[20]; long long work(long long x){ long long ret=0, u=x; int t=0, s=0…
Good Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3467    Accepted Submission(s): 1099 Problem Description If we sum up every digit of a number and the result can be exactly divided b…
If we sum up every digit of a number and the result can be exactly divided by 10, we say this number is a good number. You are required to count the number of good numbers in the range from A to B, inclusive. InputThe first line has a number T (T <=…
数位DP!!! 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #include<vector> #define ll __int64 #define pi acos(-1.0) #define MAX 50000 using namespac…
类型:数位DP 题意:定义一个Good Number 为 一个数所有位数相加的和%10==0.问[A,B]之间有多少Good Number. 方法: 正常“暴力”的定义状态:(i,d,相关量) 定义dp[i][d][mod] 为 d开头的i位数中,%10==mod的数的个数 dp[i][d][mod] = sum(dp[i-1][0~9][(mod-d+10)%10] 出口:dp[1][d][mod] = (d==mod); 代码: #include <cstdio> #include <…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722 Good Numbers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 422    Accepted Submission(s): 146 Problem Description If we sum up every digit o…
开学之后完全没时间写博客.... HDU 2089 不要62(vjudge) 数位DP 思路: 题目给出区间[n,m] ,找出不含4或62的数的个数 用一个简单的差分:先求0~m+1的个数,再减去0~n的个数. 但问题依旧不简单,再次简化为求0~i位数中不含4或62的数的个数. i= //0~9中 i= //0~99中 i= //0~999中 ...... dp[i][] //0~i位数中的吉利数 dp[i][] //0~i位数中以2打头的吉利数 dp[i][] //0~i位数中的非吉利数(含4…
题意:给定x.y.为[x,y]之间有多少个数的偶数位和减去奇数位和等于一. 个位是第一位. 样例: 10=1-0=1 所以10是这种数 思路:数位dp[i][sum][ok] i位和为sum 是否含有前导0. 然后就是由于有负数 所以依据范围把0设置为100 然后最后和等于101则为所求的数. 代码: #include"cstdlib" #include"cstdio" #include"cstring" #include"cmath&…
#include<iostream> #include<cstring> #include<cstdio> #include<vector> #include<queue> using namespace std; #define ll long long #define maxn 100050 int ok(ll n){ *;i<=n;i++){ ll sum = ,tmp = i; while(tmp){ sum += tmp%; tm…