老年公寓网站模板,wordpress所有缩略图,织梦网站手机页怎么做,江门网站推广技巧付费题目链接#xff1a;http://acm.hdu.edu.cn/showproblem.php?pid2089 有两种方法#xff1a; 1.数位DP算法 2.暴力打表——真是个好法子#xff01;#xff01;#xff01; 接下来是注意点#xff1a; 1.一般这种数组中的一个数减去一个数组的另一个数#xff0c;sum[i…题目链接http://acm.hdu.edu.cn/showproblem.php?pid2089 有两种方法 1.数位DP算法 2.暴力打表——真是个好法子 接下来是注意点 1.一般这种数组中的一个数减去一个数组的另一个数sum[i]-sum[j]这时候就要注意是sum[i]-sum[j]还是sum[i]-sum[j-1] 2.打表就不要进行多余的循环和语句 题目代码 #includeiostream
using namespace std;
int sum[1000003]{0};
int solve(int n)
{int pre0,now0;while(n0){nown%10;if(now4)return 0;if(now6pre2)return 0;nn/10;prenow;}return 1;
}
int main()
{int n,m;for(int i1;i1000000;i){sum[i]sum[i-1];if(solve(i))sum[i];}while(cinnm){if(n0m0)break;coutsum[m]-sum[n-1]endl;}
} View Code 转载于:https://www.cnblogs.com/Aiahtwo/p/10506990.html