hdu 4722 Good Numbers 规律 数位dp】的更多相关文章

#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…
类型:数位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 <…
Description 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.   Input The first line has a…
题目传送门 /* 找规律/数位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…
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 <=…
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…
数位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…
2013年南京邀请赛的铜牌题...做的非常是伤心.另外有两个不太好想到的地方.. ..a 能够等于零,另外a到b的累加和比較大.大约在2^70左右. 首先说一下解题思路. 首先统计出每一位的1的个数,然后统一进位. 设最低位为1.次低位为2,依次类推,ans[]表示这一位上有多少个1.那么有 sum += ans[i]/2,ans[i+1] += ans[i]/2; sum即为答案. 好了,如今问题转化成怎么求ans[]了. 打表查规律比較奇妙,上图不说话. 打表的代码 #include <al…
K-wolf Number 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5787 Description Alice thinks an integer x is a K-wolf number, if every K adjacent digits in decimal representation of x is pairwised different. Given (L,R,K), please count how many K-wolf…